]> git.donarmstrong.com Git - roundcube.git/blob - program/steps/settings/func.inc
Imported Upstream version 0.3
[roundcube.git] / program / steps / settings / func.inc
1 <?php
2
3 /*
4  +-----------------------------------------------------------------------+
5  | program/steps/settings/func.inc                                       |
6  |                                                                       |
7  | This file is part of the RoundCube Webmail client                     |
8  | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland                 |
9  | Licensed under the GNU GPL                                            |
10  |                                                                       |
11  | PURPOSE:                                                              |
12  |   Provide functionality for user's settings & preferences             |
13  |                                                                       |
14  +-----------------------------------------------------------------------+
15  | Author: Thomas Bruederli <roundcube@gmail.com>                        |
16  +-----------------------------------------------------------------------+
17
18  $Id: func.inc 2830 2009-08-03 18:27:53Z alec $
19
20 */
21
22 if (!$OUTPUT->ajax_call)
23   $OUTPUT->set_pagetitle(rcube_label('preferences'));
24
25 // define sections list
26 $SECTIONS['general'] = array('id' => 'general', 'section' => rcube_label('uisettings'));
27 $SECTIONS['mailbox'] = array('id' => 'mailbox', 'section' => rcube_label('mailboxview'));
28 $SECTIONS['compose'] = array('id' => 'compose', 'section' => rcube_label('messagescomposition'));
29 $SECTIONS['mailview'] = array('id' => 'mailview','section' => rcube_label('messagesdisplaying'));
30 $SECTIONS['folders'] = array('id' => 'folders', 'section' => rcube_label('specialfolders'));
31 $SECTIONS['server'] = array('id' => 'server',  'section' => rcube_label('serversettings'));
32
33
34 // similar function as /steps/settings/identities.inc::rcmail_identity_frame()
35 function rcmail_preferences_frame($attrib)
36   {
37   global $OUTPUT;
38
39   if (!$attrib['id'])
40     $attrib['id'] = 'rcmprefsframe';
41
42   $attrib['name'] = $attrib['id'];
43
44   $OUTPUT->set_env('contentframe', $attrib['name']);
45   $OUTPUT->set_env('blankpage', $attrib['src'] ? $OUTPUT->abs_url($attrib['src']) : 'program/blank.gif');
46   
47   return html::iframe($attrib);
48   }
49
50
51 function rcmail_sections_list($attrib)
52   {
53   global $RCMAIL, $SECTIONS;
54   
55   // add id to message list table if not specified
56   if (!strlen($attrib['id']))
57     $attrib['id'] = 'rcmsectionslist';
58
59   // hook + define list cols
60   $plugin = $RCMAIL->plugins->exec_hook('list_prefs_sections',
61     array('list' => $SECTIONS, 'cols' => array('section')));
62             
63   // create XHTML table
64   $out = rcube_table_output($attrib, $plugin['list'], $plugin['cols'], 'id');
65
66   // set client env
67   $RCMAIL->output->add_gui_object('sectionslist', $attrib['id']);
68   $RCMAIL->output->include_script('list.js');
69
70   return $out;
71   }
72
73
74 function rcmail_identities_list($attrib)
75   {
76   global $OUTPUT, $USER, $RCMAIL;
77
78   // add id to message list table if not specified
79   if (!strlen($attrib['id']))
80     $attrib['id'] = 'rcmIdentitiesList';
81
82   // get all identites from DB and define list of cols to be displayed
83   $plugin = $RCMAIL->plugins->exec_hook('list_identities', array(
84     'list' => $USER->list_identities(),
85     'cols' => array('name', 'email')));
86
87   // create XHTML table  
88   $out = rcube_table_output($attrib, $plugin['list'], $plugin['cols'], 'identity_id');
89   
90   // set client env
91   $OUTPUT->add_gui_object('identitieslist', $attrib['id']);
92
93   return $out;
94   }
95
96
97 // similar function as in /steps/addressbook/edit.inc
98 function get_form_tags($attrib, $action, $id = null, $hidden = null)
99   {
100   global $EDIT_FORM, $RCMAIL;
101
102   $form_start = $form_end = '';
103   
104   if (empty($EDIT_FORM)) {
105     $request_key = $action . (isset($id) ? '.'.$id : '');
106     $form_start = $RCMAIL->output->request_form(array(
107         'name' => 'form', 'method' => 'post',
108         'task' => $RCMAIL->task, 'action' => $action,
109         'request' => $request_key, 'noclose' => true) + $attrib);
110     
111     if (is_array($hidden)) {
112       $hiddenfields = new html_hiddenfield($hidden);
113       $form_start .= $hiddenfields->show();
114     }
115     
116     $form_end = !strlen($attrib['form']) ? '</form>' : '';
117
118     $EDIT_FORM = !empty($attrib['form']) ? $attrib['form'] : 'form';
119     $RCMAIL->output->add_gui_object('editform', $EDIT_FORM);
120   }
121
122   return array($form_start, $form_end);
123   }
124
125
126 // register UI objects
127 $OUTPUT->add_handlers(array(
128   'prefsframe' => 'rcmail_preferences_frame',
129   'sectionslist' => 'rcmail_sections_list',
130   'identitieslist' => 'rcmail_identities_list',
131 ));
132
133 ?>