source: branches/2.2/expressoMail1_2/inc/hook_settings.inc.php @ 3245

Revision 3245, 18.3 KB checked in by brunocosta, 14 years ago (diff)

Ticket #1267 - Implementado conforme descrito no Ticket.

  • Property svn:executable set to *
Line 
1<?php
2if(!isset($GLOBALS['phpgw_info'])){
3        $GLOBALS['phpgw_info']['flags'] = array(
4                'currentapp' => 'expressoMail1_2',
5                'nonavbar'   => true,
6                'noheader'   => true
7        );
8}
9require_once '../header.inc.php';
10
11        /**************************************************************************\
12        * eGroupWare - ExpressoMail Preferences                                    *
13        * http://www.expressolivre.org                                             *   
14        * Modified by Alexandre Felipe Muller de Souza <amuller@celepar.pr.gov.br> *
15        * --------------------------------------------                             *
16        *  This program is free software; you can redistribute it and/or modify it *
17        *  under the terms of the GNU General Public License as published by the   *
18        *  Free Software Foundation; either version 2 of the License, or (at your  *
19        *  option) any later version.                                              *
20        \**************************************************************************/
21include_once("fckeditor.php");
22$type = isset($_GET['type']) ? $_GET['type']:$GLOBALS['type']; // FIX ME
23
24//if ($type == 'user' || $type == ''){
25create_script('function exibir_ocultar()
26{
27    var type = ("'.$type.'" == "") ? "user" : "'.$type.'";
28    var use_signature_digital_cripto = document.getElementsByName(type+"[use_signature_digital_cripto]")[0];
29    var default_signature_digital_cripto = "'.$GLOBALS['phpgw_info']['default']['preferences']['expressoMail']['use_signature_digital_cripto'].'";
30
31    if (use_signature_digital_cripto)
32    {
33        var element_signature_digital = document.getElementById(type+"[use_signature_digital]");
34        var element_signature_cripto = document.getElementById(type+"[use_signature_cripto]");
35
36        switch (use_signature_digital_cripto[use_signature_digital_cripto.selectedIndex].value){
37
38            case "1":
39                element_signature_digital.style.display="";
40                element_signature_cripto.style.display="";
41                break;
42            case "0":
43                element_signature_digital.style.display="none";
44                element_signature_cripto.style.display="none";
45                break;
46            case "":
47                if (default_signature_digital_cripto){
48                    element_signature_digital.style.display="";
49                    element_signature_cripto.style.display="";
50                 }
51                 else
52                 {
53                    element_signature_digital.style.display="none";
54                    element_signature_cripto.style.display="none";
55                 }
56
57        }
58
59    }
60
61}');
62//}
63$default = false;
64create_check_box('Do you want to show common name instead of UID?','uid2cn',$default,
65        'Do you want to show common name instead of UID?');
66create_check_box('Do you want to automatically display the message header?','show_head_msg_full',$default,'');
67$default = array(
68        '25'    => '25',
69        '50'    => '50',
70        '75'    => '75',
71        '100'   => '100'
72);
73
74create_select_box('What is the maximum number of messages per page?','max_email_per_page',$default,'This is the number of messages shown in your mailbox per page');
75
76//$default = 0;
77create_check_box('Preview message text within subject column','preview_msg_subject','this exhibits a sample of message within the message subject column');
78
79//$default = 0;
80create_check_box('Preview message text within a tool-tip box','preview_msg_tip','this exhibits a sample of message within a tool-tip box');
81
82
83create_check_box('Save deleted messages in trash folder?','save_deleted_msg','When delete message, send it automatically to trash folder');
84$default = array(
85        '1'    => lang('1 day'),
86        '2'    => lang('2 days'),
87        '3'    => lang('3 days'),
88        '4'   => lang('4 days'),
89        '5'   => lang('5 days')
90);
91
92create_select_box('Delete trash messages after how many days?','delete_trash_messages_after_n_days',$default,'Delete automatically the messages in trash folder in how many days');
93create_check_box('Would you like to use local messages?','use_local_messages','Enabling this options you will be able to store messages in your local computer');
94create_check_box('Would you like to keep archived messages?','keep_archived_messages','After store email in your local computer delete it from server');
95create_check_box('Show previous message, after delete actual message?','delete_and_show_previous_message','Enable this option if you want to read the next message everytime you delete a message');
96create_check_box('Do you wanna receive an alert for new messages?','alert_new_msg','Everytime you receive new messages you will be informed');
97create_check_box('Show default view on main screen?','mainscreen_showmail','Show unread messages in your home page');
98create_check_box('Do you want to use remove attachments function?','remove_attachments_function','It allow you to remove attachments from messages');
99create_check_box('Do you want to use important flag in email editor?','use_important_flag','It allow you to send emails with important flag, but you can receive unwanted messages with important flag');
100
101//Use user folders from email
102if ($type != "" && $type != "user"){
103        $trash = $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder'];
104        $drafts = $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultDraftsFolder'];
105        $spam = $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSpamFolder'];
106        $sent = $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder'];
107        $default = Array(
108                'INBOX' =>      lang('INBOX'),
109                'INBOX' . $this->imap_delimiter . $drafts => lang($drafts),
110                'INBOX' . $this->imap_delimiter . $spam => lang($spam),
111                'INBOX' . $this->imap_delimiter . $trash => lang($trash), 
112                'INBOX' . $this->imap_delimiter . $sent => lang($sent)
113        );
114}
115else
116{
117require_once('class.imap_functions.inc.php');
118$boemailadmin = CreateObject('emailadmin.bo');
119$emailadmin_profile = $boemailadmin->getProfileList();
120$_SESSION['phpgw_info']['expressomail']['email_server'] = $boemailadmin->getProfile($emailadmin_profile[0]['profileID']);
121$_SESSION['phpgw_info']['expressomail']['user'] = $GLOBALS['phpgw_info']['user'];
122$e_server = $_SESSION['phpgw_info']['expressomail']['email_server'];
123$imap = CreateObject('expressoMail1_2.imap_functions');
124$save_in_folder_selected = $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['save_in_folder'];
125
126// Load Special Folders (Sent, Trash, Draft, Spam) from EmailAdmin (if exists, else get_lang)
127$specialFolders = array ("Trash" => lang("Trash"), "Drafts" => lang("Drafts"), "Spam" => lang("Spam"), "Sent" => lang("Sent"));
128
129foreach ($specialFolders as $key => $value){
130        if($e_server['imapDefault'.$key.'Folder'])
131                $specialFolders[$key] = $e_server['imapDefault'.$key.'Folder'];
132}
133unset($default);
134$default[-1] = lang('Select on send');
135       
136        foreach($imap -> get_folders_list(array('noSharedFolders' => true)) as $id => $folder){
137                if(!is_numeric($id))
138                        continue;
139                else{
140                        // Translate INBOX (root folder)
141                        if (strtolower($folder['folder_name']) == "inbox")
142                                $folder['folder_name'] = lang("Inbox");
143                        // Translate Special Folders
144                        elseif (($keyFolder = array_search($folder['folder_name'], $specialFolders)) !== false)
145                                $folder['folder_name'] = lang($keyFolder);
146                        // Identation for subfolders
147                        $folder_id = explode($e_server['imapDelimiter'],$folder['folder_id']);       
148                        $level = count($folder_id);
149                        $ident = '';
150                        for($i = 2; $level > 2 && $i < $level;$i++)
151                                $ident .= ' - ';
152                       
153                        $default[$folder['folder_id']] = $ident.$folder['folder_name'];
154                }               
155        }
156
157}
158create_select_box('Save sent messages in folder','save_in_folder',$default,'Save automatically sent messages in selected folder');
159create_check_box('Show TO: in place of FROM: only in Automatic SEND folder','from_to_sent','Show TO: in place of FROM: only in Automatic SEND folder');
160
161
162create_check_box('Hide menu folders?','hide_folders','You can use it if your screen does not have good resolution');
163
164$default = array(
165        '20' => lang('normal'),
166        '30' => lang('medium'),
167        '40' => lang('big')
168);
169
170$default =  array(
171    '50'    => '50',
172    '100'   => '100',
173    '150'   => '150',
174    '200'   => '200',
175    '300'   => '300',
176    '400'   => '400',
177    '65536' => lang('unlimited')
178);
179
180create_select_box('What is the maximum number of results in an e-mail search?','search_result_number',$default,'');
181
182$default =  array(
183    '1' => lang('unlimited'),
184    '2'     => '2',
185    '3'     => '3',
186    '4'     => '4',
187    '5'     => '5'
188);
189
190create_select_box('What is the minimum number of characters in searching contacts?','search_characters_number',$default,'what is the minimum number of characters in searching contacts');
191
192create_select_box('What is the height of the lines in the list of messages?','line_height',$default,'');
193create_check_box('Use dynamic contacts?','use_dynamic_contacts','Store your\'s most used contacts');
194create_check_box('Use shortcuts?','use_shortcuts','n key (Open new message)<br>ESC key (Close tab)<br>i key (print)<br>e key (forward)<br>r key (reply)<br>DELETE key (delete the current message)<br>Ctrl + up (go to previous message)<br>Ctrl + down (go to next message)<br>Shift + up or down (select multiple messages)<br>F9  key (search at catalog)<br>');
195create_check_box('Auto save draft','auto_save_draft','When you are away from computer it saves automatically the message you are writing');
196$default = array(
197        '65536' => lang('unlimited'),
198        '640' => '640',
199        '768' => '768',
200        '800' => '800',
201        '1024' => '1024',
202        '1080' => '1080'
203);
204
205create_select_box('What is the maximum size of embedded images?','image_size',$default,'When user send an email with image in body message, it changes the size');
206
207if($GLOBALS['phpgw_info']['server']['use_assinar_criptografar'])
208{
209    create_check_box('Enable digitally sign/cipher the message?','use_signature_digital_cripto','','',True,'onchange="javascript:exibir_ocultar();"');
210    if ($GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_signature_digital_cripto'])
211    {
212        create_check_box('Always sign message digitally?','use_signature_digital','');
213        create_check_box('Always cipher message digitally?','use_signature_cripto','');
214    }
215    else
216    {
217        create_check_box('Always sign message digitally?','use_signature_digital','','',True,'',False);
218        create_check_box('Always cipher message digitally?','use_signature_cripto','','',True,'',False);
219    }
220}
221
222$default = array(
223        'text' => lang('simple text'),
224        'html' => lang('rich text')
225);
226create_check_box('Insert signature automatically in new messages?','use_signature','');
227create_select_box('Signature Type','type_signature',$default,'','','','onchange="javascript:changeType(this.value);" onload="javascript:alert(this.value);"');
228
229if ($type == 'user' || $type == ''){
230        $oFCKeditor = new FCKeditor('html_signature');
231        $oFCKeditor->BasePath   = '../expressoMail1_2/js/fckeditor/';
232        $oFCKeditor->ToolbarSet = 'ExpressoLivre';
233
234        $vars = $GLOBALS['phpgw']->preferences->user[$appname];
235
236        create_html_code("signature","<div id='text_signature'>
237                <textarea rows='5' cols='50' id='user_signature' name='user[signature]'>","</textarea></div>
238                <div style='display:none;' id='html_signature'>".$oFCKeditor->Create()."</div>
239                <script language='javascript'>
240//document.getElementById('user_signature').value  = '".$vars['signature']."';
241function changeType(value){
242        var html_signature = FCKeditorAPI.GetInstance(\"html_signature\");
243        value=value.replace('d','');
244        if(value == 'text'){
245                document.getElementById('user_signature').value = html_signature.GetHTML();
246                document.getElementById(\"text_signature\").style.display = '';
247                document.getElementById(\"html_signature\").style.display = 'none';
248        }
249        else if(value == 'html'){
250                html_signature.SetHTML(document.getElementById('user_signature').value);
251                document.getElementById(\"text_signature\").style.display = 'none';
252                document.getElementById(\"html_signature\").style.display  = '';
253        }
254}
255function get_html_translation_table(table, quote_style) {
256    // http://kevin.vanzonneveld.net
257    var entities = {}, hash_map = {}, decimal = 0, symbol = '';
258    var constMappingTable = {}, constMappingQuoteStyle = {};
259    var useTable = {}, useQuoteStyle = {};
260    // Translate arguments
261    constMappingTable[0]      = 'HTML_SPECIALCHARS';
262    constMappingTable[1]      = 'HTML_ENTITIES';
263    constMappingQuoteStyle[0] = 'ENT_NOQUOTES';
264    constMappingQuoteStyle[2] = 'ENT_COMPAT';
265    constMappingQuoteStyle[3] = 'ENT_QUOTES';
266 
267    useTable       = !isNaN(table) ? constMappingTable[table] : table ? table.toUpperCase() : 'HTML_SPECIALCHARS';
268    useQuoteStyle = !isNaN(quote_style) ? constMappingQuoteStyle[quote_style] : quote_style ? quote_style.toUpperCase() : 'ENT_COMPAT';
269 
270    if (useTable !== 'HTML_SPECIALCHARS' && useTable !== 'HTML_ENTITIES') {
271        throw new Error(\"Table: \"+useTable+' not supported');
272        // return false;
273    }
274 
275    entities['38'] = '&amp;';
276    if (useTable === 'HTML_ENTITIES') {
277        entities['160'] = '&nbsp;';
278        entities['161'] = '&iexcl;';
279        entities['162'] = '&cent;';
280        entities['163'] = '&pound;';
281        entities['164'] = '&curren;';
282        entities['165'] = '&yen;';
283        entities['166'] = '&brvbar;';
284        entities['167'] = '&sect;';
285        entities['168'] = '&uml;';
286        entities['169'] = '&copy;';
287        entities['170'] = '&ordf;';
288        entities['171'] = '&laquo;';
289        entities['172'] = '&not;';
290        entities['173'] = '&shy;';
291        entities['174'] = '&reg;';
292        entities['175'] = '&macr;';
293        entities['176'] = '&deg;';
294        entities['177'] = '&plusmn;';
295        entities['178'] = '&sup2;';
296        entities['179'] = '&sup3;';
297        entities['180'] = '&acute;';
298        entities['181'] = '&micro;';
299        entities['182'] = '&para;';
300        entities['183'] = '&middot;';
301        entities['184'] = '&cedil;';
302        entities['185'] = '&sup1;';
303        entities['186'] = '&ordm;';
304        entities['187'] = '&raquo;';
305        entities['188'] = '&frac14;';
306        entities['189'] = '&frac12;';
307        entities['190'] = '&frac34;';
308        entities['191'] = '&iquest;';
309        entities['192'] = '&Agrave;';
310        entities['193'] = '&Aacute;';
311        entities['194'] = '&Acirc;';
312        entities['195'] = '&Atilde;';
313        entities['196'] = '&Auml;';
314        entities['197'] = '&Aring;';
315        entities['198'] = '&AElig;';
316        entities['199'] = '&Ccedil;';
317        entities['200'] = '&Egrave;';
318        entities['201'] = '&Eacute;';
319        entities['202'] = '&Ecirc;';
320        entities['203'] = '&Euml;';
321        entities['204'] = '&Igrave;';
322        entities['205'] = '&Iacute;';
323        entities['206'] = '&Icirc;';
324        entities['207'] = '&Iuml;';
325        entities['208'] = '&ETH;';
326        entities['209'] = '&Ntilde;';
327        entities['210'] = '&Ograve;';
328        entities['211'] = '&Oacute;';
329        entities['212'] = '&Ocirc;';
330        entities['213'] = '&Otilde;';
331        entities['214'] = '&Ouml;';
332        entities['215'] = '&times;';
333        entities['216'] = '&Oslash;';
334        entities['217'] = '&Ugrave;';
335        entities['218'] = '&Uacute;';
336        entities['219'] = '&Ucirc;';
337        entities['220'] = '&Uuml;';
338        entities['221'] = '&Yacute;';
339        entities['222'] = '&THORN;';
340        entities['223'] = '&szlig;';
341        entities['224'] = '&agrave;';
342        entities['225'] = '&aacute;';
343        entities['226'] = '&acirc;';
344        entities['227'] = '&atilde;';
345        entities['228'] = '&auml;';
346        entities['229'] = '&aring;';
347        entities['230'] = '&aelig;';
348        entities['231'] = '&ccedil;';
349        entities['232'] = '&egrave;';
350        entities['233'] = '&eacute;';
351        entities['234'] = '&ecirc;';
352        entities['235'] = '&euml;';
353        entities['236'] = '&igrave;';
354        entities['237'] = '&iacute;';
355        entities['238'] = '&icirc;';
356        entities['239'] = '&iuml;';
357        entities['240'] = '&eth;';
358        entities['241'] = '&ntilde;';
359        entities['242'] = '&ograve;';
360        entities['243'] = '&oacute;';
361        entities['244'] = '&ocirc;';
362        entities['245'] = '&otilde;';
363        entities['246'] = '&ouml;';
364        entities['247'] = '&divide;';
365        entities['248'] = '&oslash;';
366        entities['249'] = '&ugrave;';
367        entities['250'] = '&uacute;';
368        entities['251'] = '&ucirc;';
369        entities['252'] = '&uuml;';
370        entities['253'] = '&yacute;';
371        entities['254'] = '&thorn;';
372        entities['255'] = '&yuml;';
373    }
374    if (useQuoteStyle !== 'ENT_NOQUOTES') {
375        entities['34'] = '&quot;';
376    }
377    if (useQuoteStyle === 'ENT_QUOTES') {
378        entities['39'] = '&#39;';
379    }
380    entities['60'] = '&lt;';
381    entities['62'] = '&gt;';
382 
383    // ascii decimals to real symbols
384    for (decimal in entities) {
385        symbol = String.fromCharCode(decimal);
386        hash_map[symbol] = entities[decimal];
387    }
388    return hash_map;
389}
390function html_entity_decode( string, quote_style ) {
391    // http://kevin.vanzonneveld.net
392    var hash_map = {}, symbol = '', tmp_str = '', entity = '';
393    tmp_str = string.toString();
394    if (false === (hash_map = this.get_html_translation_table('HTML_ENTITIES', quote_style))) {
395        return false;
396    }
397    for (symbol in hash_map) {
398        entity = hash_map[symbol];
399        tmp_str = tmp_str.split(entity).join(symbol);
400    }
401    tmp_str = tmp_str.split('&#039;').join(\"'\");
402    return tmp_str;
403}
404
405function getTypeSignature() {
406   var elementoSelects  = document.getElementsByTagName('select');
407
408   if ( elementoSelects[18].name == \"user[type_signature]\" ) {
409        return elementoSelects[18];
410   }
411   
412   for(i=0;i<elementoSelects.length;i++){
413        if( elementoSelects[i].name == \"user[type_signature]\" ){
414                 return elementoSelects[i];
415        }
416    }
417    return null;
418}
419
420function config_form(pObj,pHandler)
421{
422        pObj.onclick=function () {
423                if (getTypeSignature().value == \"html\" || getTypeSignature().value == \"htmld\") {
424                        return pHandler(\"text\");
425                }
426        };
427
428}
429document.getElementById('user_signature').value=html_entity_decode(document.getElementById('user_signature').innerHTML);
430
431function setDefaultTypeSignature() {
432        if(getTypeSignature()){
433                getTypeSignature().options[0].value = '".$GLOBALS['phpgw']->preferences->default['expressoMail']['type_signature']."d';
434                if(getTypeSignature().value.indexOf('html')!=-1){
435                   changeType(getTypeSignature().value);
436            }
437        }else{
438                 changeType('".$GLOBALS['phpgw']->preferences->forced['expressoMail']['type_signature']."');
439        }
440}
441
442setTimeout('setDefaultTypeSignature();config_form(document.getElementsByName(\'submit\')[0],changeType);',2000);
443</script>");
444}
445?>
Note: See TracBrowser for help on using the repository browser.