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

Revision 3365, 18.8 KB checked in by brunocosta, 14 years ago (diff)

Ticket #1010 - Tornar criação automática configurável.

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