Changeset dc6c4f4 in github


Ignore:
Timestamp:
Oct 10, 2011 4:15:46 PM (20 months ago)
Author:
thomascube <thomas@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.7, release-0.8
Children:
52c2aa3
Parents:
a314823
Message:

Contact groups can have direct email addresses => distribution lists; enable 'compose' command for the selected group

Location:
program
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • program/include/rcube_addressbook.php

    r39cafac rdc6c4f4  
    297297 
    298298    /** 
     299     * Get group properties such as name and email address(es) 
     300     * 
     301     * @param string Group identifier 
     302     * @return array Group properties as hash array 
     303     */ 
     304    function get_group($group_id) 
     305    { 
     306        /* empty for address books don't supporting groups */ 
     307        return null; 
     308    } 
     309 
     310    /** 
    299311     * Create a contact group with the given name 
    300312     * 
  • program/include/rcube_contacts.php

    r39cafac rdc6c4f4  
    163163    } 
    164164 
     165 
     166    /** 
     167     * Get group properties such as name and email address(es) 
     168     * 
     169     * @param string Group identifier 
     170     * @return array Group properties as hash array 
     171     */ 
     172    function get_group($group_id) 
     173    { 
     174        $sql_result = $this->db->query( 
     175            "SELECT * FROM ".get_table_name($this->db_groups). 
     176            " WHERE del<>1". 
     177            " AND contactgroup_id=?". 
     178            " AND user_id=?", 
     179            $group_id, $this->user_id); 
     180             
     181        if ($sql_result && ($sql_arr = $this->db->fetch_assoc($sql_result))) { 
     182            $sql_arr['ID'] = $sql_arr['contactgroup_id']; 
     183            return $sql_arr; 
     184        } 
     185         
     186        return null; 
     187    } 
    165188 
    166189    /** 
     
    775798            "UPDATE ".get_table_name($this->db_groups). 
    776799            " SET del=1, changed=".$this->db->now(). 
    777             " WHERE contactgroup_id=?", 
    778             $gid 
     800            " WHERE contactgroup_id=?". 
     801            " AND user_id=?", 
     802            $gid, $this->user_id 
    779803        ); 
    780804 
     
    800824            "UPDATE ".get_table_name($this->db_groups). 
    801825            " SET name=?, changed=".$this->db->now(). 
    802             " WHERE contactgroup_id=?", 
    803             $name, $gid 
     826            " WHERE contactgroup_id=?". 
     827            " AND user_id=?", 
     828            $name, $gid, $this->user_id 
    804829        ); 
    805830 
  • program/js/app.js

    re9c47c6 rdc6c4f4  
    846846 
    847847          if (a_cids.length) 
    848             this.http_post('mailto', {_cid: a_cids.join(','), _source: this.env.source}, true); 
     848            this.http_post('mailto', { _cid: a_cids.join(','), _source: this.env.source}, true); 
     849          else if (this.env.group) 
     850            this.http_post('mailto', { _gid: this.env.group, _source: this.env.source}, true); 
    849851 
    850852          break; 
     
    38833885    } 
    38843886 
    3885     this.enable_command('compose', list.selection.length > 0); 
     3887    this.enable_command('compose', this.env.group || list.selection.length > 0); 
    38863888    this.enable_command('edit', id && writable); 
    38873889    this.enable_command('delete', list.selection.length && writable); 
     
    39693971    this.contact_list.clear(true); 
    39703972    this.show_contentframe(false); 
    3971     this.enable_command('delete', 'compose', false); 
     3973    this.enable_command('delete', false); 
     3974    this.enable_command('compose', this.env.group ? true : false); 
    39723975  }; 
    39733976 
  • program/steps/addressbook/mailto.inc

    recf295f rdc6c4f4  
    2222$cids   = rcmail_get_cids(); 
    2323$mailto = array(); 
     24$recipients = null; 
    2425 
    2526foreach ($cids as $source => $cid) 
     
    3233        $CONTACTS->set_pagesize(count($cid) + 2); // +2 to skip counting query 
    3334        $recipients = $CONTACTS->search($CONTACTS->primary_key, $cid, false, true, true, 'email'); 
     35    } 
     36} 
    3437 
    35         while (is_object($recipients) && ($rec = $recipients->iterate())) { 
    36             $emails = $CONTACTS->get_col_values('email', $rec, true); 
    37             $mailto[] = format_email_recipient($emails[0], $rec['name']); 
    38         } 
     38if (!empty($_REQUEST['_gid']) && isset($_REQUEST['_source'])) 
     39{ 
     40    $source = get_input_value('_source', RCUBE_INPUT_GPC); 
     41    $CONTACTS = $RCMAIL->get_address_book($source); 
     42     
     43    $group_id = get_input_value('_gid', RCUBE_INPUT_GPC); 
     44    $group_data = $CONTACTS->get_group($group_id); 
     45     
     46    // group has an email address assigned: use that 
     47    if ($group_data['email']) { 
     48        $mailto[] = format_email_recipient($group_data['email'][0], $group_data['name']); 
     49    } 
     50    else if ($CONTACTS->ready) { 
     51        $CONTACTS->set_group($group_id); 
     52        $CONTACTS->set_page(1); 
     53        $CONTACTS->set_pagesize(200); // limit somehow 
     54        $recipients = $CONTACTS->list_records(); 
     55    } 
     56} 
     57 
     58if ($recipients) 
     59{ 
     60    while (is_object($recipients) && ($rec = $recipients->iterate())) { 
     61        $emails = $CONTACTS->get_col_values('email', $rec, true); 
     62        $mailto[] = format_email_recipient($emails[0], $rec['name']); 
    3963    } 
    4064} 
  • program/steps/mail/autocomplete.inc

    r1a716d2 rdc6c4f4  
    8686        $abook->reset(); 
    8787        $abook->set_group($group['ID']); 
    88         $result = $abook->count(); 
     88        $group_prop = $abook->get_group($group['ID']); 
    8989 
    90         if ($result->count) { 
     90        // group (distribution list) with email address(es) 
     91        if ($group_prop['email']) { 
     92            foreach ((array)$group_prop['email'] as $email) { 
     93                $contacts[] = format_email_recipient($email, $group['name']); 
     94                if (count($contacts) >= $MAXNUM) 
     95                  break 2; 
     96            } 
     97        } 
     98        // show group with count 
     99        else if (($result = $abook->count()) && $result->count) { 
    91100          $contacts[] = array('name' => $group['name'] . ' (' . intval($result->count) . ')', 'id' => $group['ID'], 'source' => $id); 
    92101          if (count($contacts) >= $MAXNUM) 
Note: See TracChangeset for help on using the changeset viewer.