Changeset 4823 in subversion


Ignore:
Timestamp:
Jun 1, 2011 9:44:51 AM (2 years ago)
Author:
alec
Message:
  • Add popup with basic fields selection for addressbook search
Location:
trunk/roundcubemail
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/CHANGELOG

    r4819 r4823  
    22=========================== 
    33 
     4- Add popup with basic fields selection for addressbook search 
    45- Case-insensitive matching in autocompletion (#1487933) 
    56- Added option to force spellchecking before sending a message (#1485458) 
  • trunk/roundcubemail/config/main.inc.php.dist

    r4816 r4823  
    675675$rcmail_config['search_mods'] = null;  // Example: array('*' => array('subject'=>1, 'from'=>1), 'Sent' => array('subject'=>1, 'to'=>1)); 
    676676 
     677// Defaults of the addressbook search field configuration. 
     678$rcmail_config['addressbook_search_mods'] = null;  // Example: array('name'=>1, 'firstname'=>1, 'surname'=>1, 'email'=>1, '*'=>1); 
     679 
    677680// 'Delete always' 
    678681// This setting reflects if mail should be always deleted 
  • trunk/roundcubemail/program/include/rcube_contacts.php

    r4768 r4823  
    193193        // determine whether we have to parse the vcard or if only db cols are requested 
    194194        $read_vcard = !$cols || count(array_intersect($cols, $this->table_cols)) < count($cols); 
    195          
     195 
    196196        while ($sql_result && ($sql_arr = $this->db->fetch_assoc($sql_result))) { 
    197197            $sql_arr['ID'] = $sql_arr[$this->primary_key]; 
     
    256256                $where[] = 'c.' . $this->primary_key.' IN ('.$ids.')'; 
    257257            } 
    258             else if ($strict) { 
    259                 $where[] = $this->db->quoteIdentifier($col).' = '.$this->db->quote($value); 
    260             } 
    261258            else if ($col == '*') { 
    262259                $words = array(); 
     
    264261                    $words[] = $this->db->ilike('words', '%'.$word.'%'); 
    265262                $where[] = '(' . join(' AND ', $words) . ')'; 
    266               } 
    267             else 
     263            } 
     264            else if ($strict) { 
     265                $where[] = $this->db->quoteIdentifier($col).' = '.$this->db->quote($value); 
     266            } 
     267            else if (in_array($col, $this->table_cols)) { 
    268268                $where[] = $this->db->ilike($col, '%'.$value.'%'); 
     269            } 
    269270        } 
    270271 
  • trunk/roundcubemail/program/include/rcube_ldap.php

    r4752 r4823  
    480480        $filter = '(|'; 
    481481        $wc = !$strict && $this->prop['fuzzy_search'] ? '*' : ''; 
    482         if ($fields != '*') 
     482        if ($fields == '*') 
    483483        { 
    484484            // search_fields are required for fulltext search 
    485             if (!$this->prop['search_fields']) 
     485            if (empty($this->prop['search_fields'])) 
    486486            { 
    487487                $this->set_error(self::ERROR_SEARCH, 'nofulltextsearch'); 
     
    489489                return $this->result; 
    490490            } 
    491         } 
    492          
    493         if (is_array($this->prop['search_fields'])) 
    494         { 
    495             foreach ($this->prop['search_fields'] as $k => $field) 
    496                 $filter .= "($field=$wc" . $this->_quote_string($value) . "$wc)"; 
     491            if (is_array($this->prop['search_fields'])) 
     492            { 
     493                foreach ($this->prop['search_fields'] as $k => $field) 
     494                    $filter .= "($field=$wc" . $this->_quote_string($value) . "$wc)"; 
     495            } 
    497496        } 
    498497        else 
  • trunk/roundcubemail/program/js/app.js

    r4818 r4823  
    33333333  { 
    33343334    if (value != '') { 
    3335       var addurl = ''; 
     3335      var n, addurl = '', mods_arr = [], 
     3336        mods = this.env.search_mods, 
     3337        mbox = this.env.mailbox, 
     3338        lock = this.set_busy(true, 'searching'); 
     3339 
    33363340      if (this.message_list) { 
    33373341        this.clear_message_list(); 
    3338         if (this.env.search_mods) { 
    3339           var mods = this.env.search_mods[this.env.mailbox] ? this.env.search_mods[this.env.mailbox] : this.env.search_mods['*']; 
    3340           if (mods) { 
    3341             var head_arr = []; 
    3342             for (var n in mods) 
    3343               head_arr.push(n); 
    3344             addurl += '&_headers='+head_arr.join(','); 
    3345           } 
    3346         } 
     3342        if (mods) 
     3343          mods = mods[mbox] ? mods[mbox] : mods['*']; 
    33473344      } else if (this.contact_list) { 
    33483345        this.contact_list.clear(true); 
     
    33503347      } 
    33513348 
     3349      if (mods) { 
     3350        for (n in mods) 
     3351          mods_arr.push(n); 
     3352        addurl += '&_headers='+mods_arr.join(','); 
     3353      } 
     3354 
    33523355      if (this.gui_objects.search_filter) 
    33533356        addurl += '&_filter=' + this.gui_objects.search_filter.value; 
     
    33553358      // reset vars 
    33563359      this.env.current_page = 1; 
    3357       var lock = this.set_busy(true, 'searching'); 
    33583360      this.http_request('search', '_q='+urlencode(value) 
    3359         + (this.env.mailbox ? '&_mbox='+urlencode(this.env.mailbox) : '') 
     3361        + (mbox ? '&_mbox='+urlencode(mbox) : '') 
    33603362        + (this.env.source ? '&_source='+urlencode(this.env.source) : '') 
    33613363        + (this.env.group ? '&_gid='+urlencode(this.env.group) : '') 
  • trunk/roundcubemail/program/localization/en_US/labels.inc

    r4816 r4823  
    272272$labels['assistant'] = 'Assistant'; 
    273273$labels['spouse'] = 'Spouse'; 
     274$labels['allfields'] = 'All fields'; 
    274275 
    275276$labels['typehome']   = 'Home'; 
  • trunk/roundcubemail/program/localization/pl_PL/labels.inc

    r4816 r4823  
    459459ÅŒki adresowej'; 
    460460$labels['spellcheckbeforesend'] = 'Przed wysłaniem wiadomości sprawdzaj pisownię'; 
     461$labels['allfields'] = 'Wszystkie pola'; 
    461462 
    462463?> 
  • trunk/roundcubemail/program/steps/addressbook/func.inc

    r4764 r4823  
    2020*/ 
    2121 
     22$SEARCH_MODS_DEFAULT = array('name'=>1, 'firstname'=>1, 'surname'=>1, 'email'=>1, '*'=>1); 
     23 
    2224// add list of address sources to client env 
    2325$js_list = $RCMAIL->get_address_sources(); 
     
    4042else 
    4143    $CONTACTS->set_page(isset($_SESSION['page']) ?$_SESSION['page'] : 1); 
    42    
     44 
    4345if (!empty($_REQUEST['_gid'])) 
    4446    $CONTACTS->set_group(get_input_value('_gid', RCUBE_INPUT_GPC)); 
     
    5254$OUTPUT->set_env('readonly', $CONTACTS->readonly, false); 
    5355if (!$OUTPUT->ajax_call) { 
     56    $search_mods = $RCMAIL->config->get('addressbook_search_mods', $SEARCH_MODS_DEFAULT); 
     57    $OUTPUT->set_env('search_mods', $search_mods); 
    5458    $OUTPUT->set_env('address_sources', $js_list); 
    5559    $OUTPUT->set_pagetitle(rcube_label('addressbook')); 
  • trunk/roundcubemail/program/steps/addressbook/search.inc

    r4812 r4823  
    2323$_SESSION['page'] = 1; 
    2424 
     25// get input 
    2526$search = trim(get_input_value('_q', RCUBE_INPUT_GET, true)); 
    26 $search_request = md5('addr'.$search); 
     27$fields = explode(',', get_input_value('_headers', RCUBE_INPUT_GET)); 
     28 
     29if (empty($fields)) { 
     30    $fields = $SEARCH_MODS_DEFAULT; 
     31} 
     32 
     33$search_request = md5('addr'.$search.implode($fields, ',')); 
     34 
     35// update search_mods setting 
     36$search_mods = array_fill_keys($fields, 1); 
     37$RCMAIL->user->save_prefs(array('addressbook_search_mods' => $search_mods)); 
     38 
     39if ($fields['all'] || count($fields) == count($SEARCH_MODS_DEFAULT)) { 
     40    $fields = '*'; 
     41} 
    2742 
    2843// get contacts for this user 
    29 $result = $CONTACTS->search('*', $search); 
     44$result = $CONTACTS->search($fields, $search); 
    3045 
    3146// save search settings in session 
    3247$_SESSION['search'][$search_request] = $CONTACTS->get_search_set(); 
    3348 
    34 if ($result->count > 0) 
    35 { 
    36   // create javascript list 
    37   rcmail_js_contacts_list($result); 
     49if ($result->count > 0) { 
     50    // create javascript list 
     51    rcmail_js_contacts_list($result); 
    3852} 
    39 else 
    40 { 
     53else { 
    4154  $OUTPUT->show_message('nocontactsfound', 'notice'); 
    4255} 
     
    4659$OUTPUT->set_env('pagecount', ceil($result->count / $CONTACTS->page_size)); 
    4760$OUTPUT->command('set_rowcount', rcmail_get_rowcount_text()); 
    48    
     61 
    4962// send response 
    5063$OUTPUT->send(); 
  • trunk/roundcubemail/skins/default/common.css

    r4808 r4823  
    618618} 
    619619 
    620  
    621620/***** roundcube webmail pre-defined classes *****/ 
    622621 
     
    814813  margin-top: 2px; 
    815814  padding-top: 2px; 
     815} 
     816 
     817#searchmenu 
     818{ 
     819  width: 160px; 
     820} 
     821 
     822#searchmenu ul.toolbarmenu 
     823{ 
     824  margin: 0; 
     825} 
     826 
     827#searchmenu ul.toolbarmenu li 
     828{ 
     829  margin: 1px 4px 1px; 
    816830} 
    817831 
  • trunk/roundcubemail/skins/default/functions.js

    r4775 r4823  
    187187 
    188188    if (rcmail.env.search_mods) { 
    189       var search_mods = rcmail.env.search_mods[rcmail.env.mailbox] ? rcmail.env.search_mods[rcmail.env.mailbox] : rcmail.env.search_mods['*']; 
    190       for (var n in search_mods) 
    191         $('#s_mod_' + n).prop('checked', true); 
     189      var n, mbox = rcmail.env.mailbox, mods = rcmail.env.search_mods; 
     190 
     191      if (rcmail.env.task != 'addressbook') { 
     192        mods = mods[mbox] ? mods[mbox] : mods['*']; 
     193 
     194        for (n in mods) 
     195          $('#s_mod_' + n).prop('checked', true); 
     196      } 
     197      else { 
     198        if (mods['*']) 
     199          $('input:checkbox[name="s_mods[]"]').map(function() { 
     200            this.checked = true; 
     201            this.disabled = this.value != '*'; 
     202          }); 
     203        else { 
     204          for (n in mods) 
     205            $('#s_mod_' + n).prop('checked', true); 
     206        } 
     207      } 
    192208    } 
    193209  } 
     
    197213set_searchmod: function(elem) 
    198214{ 
    199   if (!rcmail.env.search_mods) 
    200     rcmail.env.search_mods = {}; 
    201  
    202   if (!rcmail.env.search_mods[rcmail.env.mailbox]) 
    203     rcmail.env.search_mods[rcmail.env.mailbox] = rcube_clone_object(rcmail.env.search_mods['*']); 
    204  
    205   if (!elem.checked) 
    206     delete(rcmail.env.search_mods[rcmail.env.mailbox][elem.value]); 
    207   else 
    208     rcmail.env.search_mods[rcmail.env.mailbox][elem.value] = elem.value; 
     215  var task = rcmail.env.task, 
     216    mods = rcmail.env.search_mods, 
     217    mbox = rcmail.env.mailbox; 
     218 
     219  if (!mods) 
     220    mods = {}; 
     221 
     222  if (task == 'mail') { 
     223    if (!mods[mbox]) 
     224      mods[mbox] = rcube_clone_object(mods['*']); 
     225    if (!elem.checked) 
     226      delete(mods[mbox][elem.value]); 
     227    else 
     228      mods[mbox][elem.value] = 1; 
     229  } 
     230  else { //addressbook 
     231    if (!elem.checked) 
     232      delete(mods[elem.value]); 
     233    else 
     234      mods[elem.value] = 1; 
     235 
     236    // mark all fields 
     237    if (elem.value == '*') { 
     238      $('input:checkbox[name="s_mods[]"]').map(function() { 
     239        if (this == elem) 
     240          return; 
     241 
     242        if (elem.checked) { 
     243          mods[this.value] = 1; 
     244          this.checked = true; 
     245          this.disabled = true; 
     246        } 
     247        else { 
     248          this.disabled = false; 
     249        } 
     250      }); 
     251    } 
     252  } 
     253 
     254  rcmail.env.search_mods = mods; 
    209255}, 
    210256 
  • trunk/roundcubemail/skins/default/mail.css

    r4808 r4823  
    153153{ 
    154154  padding-left: 2px; 
    155 } 
    156  
    157 #searchmenu 
    158 { 
    159   width: 160px; 
    160 } 
    161  
    162 #searchmenu ul.toolbarmenu 
    163 { 
    164   margin: 0; 
    165 } 
    166  
    167 #searchmenu ul.toolbarmenu li 
    168 { 
    169   margin: 1px 4px 1px; 
    170155} 
    171156 
  • trunk/roundcubemail/skins/default/templates/addressbook.html

    r4538 r4823  
    3030 
    3131<div id="quicksearchbar"> 
    32 <roundcube:button name="searchmenulink" id="searchmenulink" image="/images/icons/glass.png" /> 
     32<roundcube:button name="searchmenulink" id="searchmenulink" image="/images/icons/glass_roll.png" onclick="rcmail_ui.show_popup('searchmenu');return false" title="searchmod" /> 
    3333<roundcube:object name="searchform" id="quicksearchbox" /> 
    3434<roundcube:button command="reset-search" id="searchreset" image="/images/icons/reset.gif" title="resetsearch" /> 
     35</div> 
     36 
     37<div id="searchmenu" class="popupmenu"> 
     38  <ul class="toolbarmenu"> 
     39    <li><input type="checkbox" name="s_mods[]" value="name" id="s_mod_name" onclick="rcmail_ui.set_searchmod(this)" /><label for="s_mod_name"><roundcube:label name="name" /></label></li> 
     40    <li><input type="checkbox" name="s_mods[]" value="firstname" id="s_mod_firstname" onclick="rcmail_ui.set_searchmod(this)" /><label for="s_mod_firstname"><roundcube:label name="firstname" /></label></li> 
     41    <li><input type="checkbox" name="s_mods[]" value="surname" id="s_mod_surname" onclick="rcmail_ui.set_searchmod(this)" /><label for="s_mod_surname"><roundcube:label name="surname" /></label></li> 
     42    <li><input type="checkbox" name="s_mods[]" value="email" id="s_mod_email" onclick="rcmail_ui.set_searchmod(this)" /><label for="s_mod_email"><roundcube:label name="email" /></label></li> 
     43    <li><input type="checkbox" name="s_mods[]" value="*" id="s_mod_all" onclick="rcmail_ui.set_searchmod(this)" /><label for="s_mod_all"><roundcube:label name="allfields" /></label></li> 
     44<!-- 
     45    <li class="separator_below"> 
     46    <li><roundcube:button command="advsearch" type="link" label="advsearch" style="padding-left: 0" classAct="active" /></li> 
     47--> 
     48  </ul> 
    3549</div> 
    3650 
Note: See TracChangeset for help on using the changeset viewer.