Changeset 413


Ignore:
Timestamp:
09/11/08 16:42:44 (16 years ago)
Author:
rafaelraymundo
Message:

Melhoria implementada, relativo a ocorrencia #314 da comunidade.
Contatos dinamicos no envio de emails de forma configuravel.

Location:
trunk/expressoMail1_2
Files:
2 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/expressoMail1_2/inc/class.db_functions.inc.php

    r205 r413  
    33define('PHPGW_API_INC','../phpgwapi/inc');       
    44include_once(PHPGW_API_INC.'/class.db.inc.php'); 
    5          
     5include_once('class.dynamic_contacts.inc.php'); 
     6 
    67class db_functions 
    78{        
     
    142143        } 
    143144 
    144         function get_dropdown_contacts(){ 
     145        function get_dropdown_contacts() 
     146        { 
     147                $dynamic_contact = new dynamic_contacts(); 
    145148                 
    146149                $contacts = $this -> get_cc_contacts(); 
    147150                $groups = $this -> get_cc_groups(); 
     151                $dynamic = $dynamic_contact->dynamic_contact_toString(); 
    148152                 
    149153                if(($contacts) && ($groups)) 
     
    155159                elseif ((!$contacts) && ($groups)) 
    156160                        $stringDropDownContacts = $groups; 
    157                                          
     161                if (($dynamic) && (($groups) || ($contacts))) 
     162                        $stringDropDownContacts .= ',' . $dynamic; 
     163                else  
     164                        if ($dynamic) 
     165                                $stringDropDownContacts = $dynamic; 
     166                                 
    158167                return $stringDropDownContacts;  
    159168        } 
     
    257266                return $result; 
    258267        } 
     268         
     269        function get_dynamic_contacts() 
     270        {                                
     271                // Pesquisa os emails e ultima inserção nos contatos dinamicos. 
     272                if(!$this->db->select('phpgw_expressomail_contacts','data', 
     273                                                  'id_owner ='.$this -> user_id, 
     274                                                  __LINE__,__FILE__)) 
     275                { 
     276                return $this->db->Error; 
     277        } 
     278                while($this->db->next_record()) 
     279                { 
     280                        $result[] = $this->db->row(); 
     281                } 
     282                foreach($result as $item)  
     283                { 
     284                        $contacts = unserialize($item['data']); 
     285                } 
     286                if (count($contacts) == 0) 
     287                {                        
     288                        return null; 
     289                }        
     290                return $contacts; 
     291        } 
     292         
     293        function update_contacts($contacts=array()) 
     294        {                        
     295                // Atualiza um email nos contatos dinamicos. 
     296                if(!$this->db->update('phpgw_expressomail_contacts ','data=\''.serialize($contacts).'\'', 
     297                                                          'id_owner ='.$this -> user_id, 
     298                                                          __LINE__,__FILE__)) 
     299                { 
     300                        return $this->db->Error; 
     301                } 
     302        return $contacts; 
     303        }        
     304         
     305        function insert_contact($contact)        
     306        { 
     307                $contacts[] = array( 'timestamp'        => time(), 
     308                                                                'email'         => $contact ); 
     309 
     310                // Insere um email nos contatos dinamicos.       
     311                $query = 'INSERT INTO phpgw_expressomail_contacts (data, id_owner)  ' . 
     312                                        'values ( \''.serialize($contacts).'\', '.$this->user_id.')'; 
     313                 
     314                if(!$this->db->query($query,__LINE__,__FILE__)) 
     315                return $this->db->Error; 
     316        return $contacts; 
     317        } 
     318         
     319        function remove_dynamic_contact($user_id,$line,$file) 
     320        { 
     321                $where = $user_id.' = id_owner'; 
     322                $this->db->delete('phpgw_expressomail_contacts',$where,$line,$file);     
     323        } 
    259324} 
    260325?> 
  • trunk/expressoMail1_2/inc/class.imap_functions.inc.php

    r411 r413  
    12461246                                $sent = trim($sent);                                                                                             
    12471247                                error_log("$now - $userip - $sent [$subject] - $userid => $addrs\r\n", 3, "/home/expressolivre/mail_senders.log"); 
     1248                        } 
     1249                        if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_dynamic_contacts']) 
     1250                        { 
     1251                                $contacts = new dynamic_contacts(); 
     1252                                $contacts->add_dynamic_contacts($toaddress.$ccaddress.$ccoaddress); 
    12481253                        } 
    12491254                        return true; 
  • trunk/expressoMail1_2/index.php

    r395 r413  
    8282                'font_size'                                             => $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['font_size'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['font_size'] : "11", 
    8383                'use_shortcuts'                                         => $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_shortcuts'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_shortcuts'] : "0", 
    84                 'auto_save_draft'                                       => $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['auto_save_draft'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['auto_save_draft'] : "0" 
     84                'auto_save_draft'                                       => $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['auto_save_draft'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['auto_save_draft'] : "0", 
     85                        'use_dynamic_contacts'                          => $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_dynamic_contacts'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_dynamic_contacts'] : "0" 
    8586                 
    8687        ); 
     
    126127        // End Set Anti-Spam options. 
    127128 
     129        // Dynamic contact. 
     130        $_SESSION['phpgw_info']['server']['expressomail']['expressoMail_Number_of_dynamic_contacts'] = $current_config['expressoMail_Number_of_dynamic_contacts']; 
    128131 
    129132       // Set Imap Folder names options 
  • trunk/expressoMail1_2/js/DropDownContacts.js

    r376 r413  
    5959                                tmp[1] = tmp[1].replace(tmp_mail, tmp_mail.bold()); 
    6060                                tmp[0] = tmp[0].replace(tmp_mail, tmp_mail.bold()); 
    61                                 match_contacts[match_index] = '"' + tmp[0] + '" <' + tmp[1] + '>'; 
     61                                if(tmp[0] == '') 
     62                                        match_contacts[match_index] = tmp[0] + ' <' + tmp[1] + '>'; 
     63                                else 
     64                                        match_contacts[match_index] = '$"' + tmp[0] + '" <' + tmp[1] + '>'; 
    6265                                match_index++; 
    6366                        } 
  • trunk/expressoMail1_2/js/main.js

    r389 r413  
    856856                        write_msg(get_lang('Your message was sent and save.')); 
    857857                        wfolders.alert = false; 
     858                        init(); 
    858859                }else{ 
    859                         write_msg(get_lang('Your message was sent.'));           
     860                        write_msg(get_lang('Your message was sent.')); 
     861                        init();          
    860862                } 
    861863                if ((! newMessageTab.toPreserve[ID]) && (newMessageTab.imapUid[ID] != 0)) 
  • trunk/expressoMail1_2/js/preferences.js

    r340 r413  
    7373                                "<option value='15'>"+get_lang("Big")+"</option>"+ 
    7474                                "</select></td></tr>"+ 
     75                                "<tr><td> - " + get_lang("Use dynamic contacts?") + "</td>"+ 
     76                                "<td><input type='checkBox' id='use_dynamic_contacts' name='use_dynamic_contacts'></td></tr>"+ 
     77                                "<tr><td> - " + get_lang("Use shortcuts?") + "</td>"+ 
     78                                "<td><input type='checkBox' id='use_shortcuts' name='use_shortcuts'></td></tr>"+ 
    7579                                "<tr><td> - " + get_lang("Auto save draft") + "?</td>"+ 
    7680                                "<td><input type='checkBox' id='auto_save_draft' name='auto_save_draft'></td></tr>"+ 
    77                                 "<tr><td> - " + get_lang("Use shortcuts?") + "</td>"+ 
    78                                 "<td><input type='checkBox' id='use_shortcuts' name='use_shortcuts'></td></tr>"+ 
    7981                                "<tr><td nowrap> - " + get_lang('Insert signature automatically in new messages?') + "</td>"+ 
    8082                                "<td><input type='checkBox' id='use_signature' name='use_signature'></td>"+ 
     
    140142                                if(sel_size_font.options[i].value == preferences.font_size){sel_size_font.options[i].selected = true;} 
    141143                        } 
     144                var use_dynamic_contacts = Element("use_dynamic_contacts"); 
     145                        if (preferences.use_dynamic_contacts == 1) { 
     146                                use_dynamic_contacts.checked = true; 
     147                        } 
    142148                var use_signature = Element("use_signature"); 
    143149                        if( preferences.use_signature == 1){ 
     
    147153                        txt_signature.value = preferences.signature; 
    148154                 
     155                if ((_this.number_of_contacts < 1) || isNaN(_this.number_of_contacts))  
     156                { 
     157                        Element("use_dynamic_contacts").checked = false; 
     158                        Element("use_dynamic_contacts").disabled = 'disabled'; 
     159                } 
    149160                if( preferences.use_shortcuts == 1) Element("use_shortcuts").checked = true; 
    150161                if( preferences.auto_save_draft == 1) Element("auto_save_draft").checked = true; 
     
    154165        // Salva as opções do form; 
    155166        Preferences.prototype.save_form = function(){ 
    156          
    157            //var prefe_string;                   
     167                 
     168                var _this = this;        
     169            //var prefe_string;                  
    158170                var reload_page = false; 
    159171 
     
    172184            else if(preferences.auto_save_draft != Element("auto_save_draft").checked) 
    173185                        reload_page = true; 
     186                else if(preferences.use_dynamic_contacts != Element("use_dynamic_contacts").checked) 
     187                { 
     188                        reload_page = true; 
     189                        _this.delete_dynamic_contacts(); 
     190                } 
    174191                                 
    175192                preferences.max_email_per_page = Element("sel_num_max").value;  
     
    185202                preferences.use_signature = Element("use_signature").checked ? 1 : 0; 
    186203                preferences.signature = Element("txt_signature").value; 
     204                preferences.use_dynamic_contacts = Element("use_dynamic_contacts").checked ? 1 : 0; 
    187205                preferences.use_shortcuts = Element("use_shortcuts").checked ? 1 : 0; 
    188206                preferences.auto_save_draft = Element("auto_save_draft").checked ? 1 : 0; 
    189                  
    190                 var _this = this; 
    191                  
     207 
     208 
    192209                var handler_preferences = function(data){ 
    193210                        if(data && data.success){ 
     
    234251                document.getElementById("use_signature").checked = false;                
    235252                document.getElementById('txt_signature').value = ""; 
     253                document.getElementById("use_dynamic_contacts").checked = false; 
    236254        } 
    237255 
     
    246264                        div.style.paddingLeft = "10px";                  
    247265                        var title = get_lang("ExpressoMail 1.2 Configuration"); 
    248                         var wHeight = "420px"; 
     266                        var wHeight = "480px"; 
    249267                        var wWidth =  "530px"; 
    250268 
     
    270288                win.open(); 
    271289        } 
     290         
     291        Preferences.prototype.delete_dynamic_contacts = function(){ 
     292                var handler = function(data){} 
     293                var args   = "$this.dynamic_contacts.delete_dynamic_contacts"; 
     294                var params = ""; 
     295                cExecute(args,handler,params); 
     296        } 
     297        Preferences.prototype.get_number_of_contacts = function(){ 
     298                var _this = this; 
     299                var handler = function(data){ 
     300                        _this.number_of_contacts = data; 
     301                } 
     302                var args   = "$this.dynamic_contacts.get_number_of_contacts"; 
     303                var params = ""; 
     304                cExecute(args,handler,params); 
     305        } 
    272306// Cria o objeto         
    273307        var prefe; 
    274308        prefe = new Preferences(); 
     309        prefe.get_number_of_contacts(); 
  • trunk/expressoMail1_2/preferences.php

    r389 r413  
    5050                        $GLOBALS['phpgw']->template->set_var('checked_mainscreen_showmail',''); 
    5151 
     52                if (!is_numeric($_SESSION['phpgw_info']['server']['expressomail']['expressoMail_Number_of_dynamic_contacts']))  
     53                {                                                                                
     54                        $GLOBALS['phpgw']->template->set_var('checked_dynamic_contacts',''); 
     55                        $GLOBALS['phpgw']->template->set_var('checked_dynamic_contacts','disabled'); 
     56                } 
     57                else 
     58                { 
     59                        if ($GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_dynamic_contacts']) 
     60                                $GLOBALS['phpgw']->template->set_var('checked_dynamic_contacts','checked'); 
     61                        else 
     62                                $GLOBALS['phpgw']->template->set_var('checked_dynamic_contacts',''); 
     63                } 
     64 
    5265                if ($GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_shortcuts']) 
    5366                        $GLOBALS['phpgw']->template->set_var('checked_shortcuts','checked'); 
     
    147160                else 
    148161                        $GLOBALS['phpgw']->preferences->add('expressoMail','mainscreen_showmail',$_POST['mainscreen_showmail']); 
     162 
     163                if (!is_numeric($_SESSION['phpgw_info']['server']['expressomail']['expressoMail_Number_of_dynamic_contacts']))  
     164                {                                                                                
     165                        $GLOBALS['phpgw']->template->set_var('checked_dynamic_contacts',''); 
     166                        $GLOBALS['phpgw']->template->set_var('checked_dynamic_contacts','disabled'); 
     167                } 
     168                else 
     169                { 
     170                        if ($GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_dynamic_contacts']) 
     171                        { 
     172                                $GLOBALS['phpgw']->preferences->change('expressoMail','use_dynamic_contacts',$_POST['use_dynamic_contacts']); 
     173                                if($_POST['use_dynamic_contacts'] == '') 
     174                                { 
     175                                        $contacts = CreateObject('expressoMail1_2.dynamic_contacts'); 
     176                                        $contacts->delete_dynamic_contacts(); 
     177                                } 
     178                        } 
     179                        else 
     180                        $GLOBALS['phpgw']->preferences->add('expressoMail','use_dynamic_contacts',$_POST['use_dynamic_contacts']); 
     181                } 
    149182 
    150183                if ($GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_shortcuts']) 
     
    220253        $GLOBALS['phpgw']->template->set_var('lang_line_height',lang('What is the height of the lines in the list of messages?')); 
    221254        $GLOBALS['phpgw']->template->set_var('lang_font_size',lang('What the font size in the list of messages?')); 
     255        $GLOBALS['phpgw']->template->set_var('lang_use_dynamic_contacts',lang('Use dynamic contacts?')); 
    222256        $GLOBALS['phpgw']->template->set_var('lang_use_shortcuts',lang('Use shortcuts?')); 
    223257        $GLOBALS['phpgw']->template->set_var('lang_auto_save_draft',lang('Auto save draft')); 
  • trunk/expressoMail1_2/setup/setup.inc.php

    r381 r413  
    1717//      $setup_info['expressoMail1_2']['tables'][]      = 'phpgw_expressoMail1_2_apps'; 
    1818//      $setup_info['expressoMail1_2']['tables'][]              = 'phpgw_expressoMail1_2_log'; 
     19        $setup_info['expressoMail1_2']['tables'][]              = 'phpgw_expressomail_contacts'; 
    1920        $setup_info['expressoMail1_2']['enable']        = 1; 
    2021 
  • trunk/expressoMail1_2/setup/tables_current.inc.php

    r2 r413  
    99        *  option) any later version.                                                                                                                                                                            * 
    1010        \**************************************************************************/ 
    11  
     11/* 
    1212        $phpgw_baseline = array( 
    1313                'phpgw_expressoMail_serverconfig' => array( 
     
    3434                ) 
    3535        ); 
     36*/ 
    3637?> 
  • trunk/expressoMail1_2/templates/default/config.tpl

    r197 r413  
    4242    </td> 
    4343   </tr> 
     44   <tr bgcolor="{row_on}"> 
     45    <td>{lang_Number_of_dynamic_contacts}</td> 
     46    <td> 
     47        <input size="1" name="newsettings[expressoMail_Number_of_dynamic_contacts]" value="{value_expressoMail_Number_of_dynamic_contacts}">  
     48    </td> 
     49   </tr> 
    4450<!-- END body --> 
    4551<!-- BEGIN footer --> 
  • trunk/expressoMail1_2/templates/default/preferences.tpl

    r389 r413  
    9090    </tr> 
    9191    <tr bgcolor="{tr_color1}"> 
     92        <td>{lang_use_dynamic_contacts}</td> 
     93        <td align="center"> 
     94                        <input type="checkbox" name="use_dynamic_contacts" value=1 {checked_dynamic_contacts}> 
     95        </td> 
     96    </tr> 
     97    <tr bgcolor="{tr_color2}"> 
    9298        <td> 
    9399                        {lang_use_shortcuts} 
     
    98104    </tr> 
    99105 
    100     <tr bgcolor="{tr_color2}"> 
     106    <tr bgcolor="{tr_color1}"> 
    101107        <td> 
    102108                        {lang_auto_save_draft} 
Note: See TracChangeset for help on using the changeset viewer.