Changeset 3457 in subversion


Ignore:
Timestamp:
Apr 1, 2010 2:39:06 AM (3 years ago)
Author:
thomasb
Message:

Add server-side plugin hooks to address group functions + better action names

Location:
trunk/roundcubemail
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/index.php

    r3449 r3457  
    222222    'group-rename' => 'groups.inc', 
    223223    'group-delete' => 'groups.inc', 
    224     'group-addmember' => 'groups.inc', 
    225     'group-delmenber' => 'groups.inc', 
     224    'group-addmembers' => 'groups.inc', 
     225    'group-delmembers' => 'groups.inc', 
    226226  ), 
    227227   
  • trunk/roundcubemail/program/js/app.js

    r3449 r3457  
    32393239     
    32403240    // insert all members of a group 
    3241     if (typeof this.env.contacts[id] == 'object' && this.env.contacts[id].id) { 
    3242       insert += this.env.contacts[id].name + ', '; 
    3243       this.group2expand = $.extend({}, this.env.contacts[id]); 
    3244       this.group2expand.input = this.ksearch_input; 
    3245       this.http_request('group-expand', '_source='+urlencode(this.env.contacts[id].source)+'&_gid='+urlencode(this.env.contacts[id].id), false); 
     3241    if (typeof this.env.contacts[id] == 'object' && this.env.contacts[id].members) { 
     3242      for (var i=0; i < this.env.contacts[id].members.length; i++) 
     3243        insert += this.env.contacts[id].members[i] + ', '; 
    32463244    } 
    32473245    else if (typeof this.env.contacts[id] == 'string') 
     
    32543252    if (this.ksearch_input.setSelectionRange) 
    32553253      this.ksearch_input.setSelectionRange(cpos, cpos); 
    3256   }; 
    3257    
    3258   this.replace_group_recipients = function(id, recipients) 
    3259   { 
    3260     if (this.group2expand && this.group2expand.id == id) { 
    3261       this.group2expand.input.value = this.group2expand.input.value.replace(this.group2expand.name, recipients); 
    3262       this.group2expand = null; 
    3263     } 
    32643254  }; 
    32653255 
     
    35203510 
    35213511    if (to.type == 'group') 
    3522       this.http_post('group-addmember', '_cid='+urlencode(cid)+'&_source='+urlencode(this.env.source)+'&_gid='+urlencode(to.id)); 
     3512      this.http_post('group-addmembers', '_cid='+urlencode(cid)+'&_source='+urlencode(this.env.source)+'&_gid='+urlencode(to.id)); 
    35233513    else if (to.id != this.env.source && cid && this.env.address_sources[to.id] && !this.env.address_sources[to.id].readonly) 
    35243514      this.http_post('copy', '_cid='+urlencode(cid)+'&_source='+urlencode(this.env.source)+'&_to='+urlencode(to.id)); 
     
    35593549    // send request to server 
    35603550    if (this.env.group) 
    3561       this.http_post('group-delmember', '_cid='+urlencode(a_cids.join(','))+'&_source='+urlencode(this.env.source)+'&_gid='+urlencode(this.env.group)+qs); 
     3551      this.http_post('group-delmembers', '_cid='+urlencode(a_cids.join(','))+'&_source='+urlencode(this.env.source)+'&_gid='+urlencode(this.env.group)+qs); 
    35623552    else 
    35633553      this.http_post('delete', '_cid='+urlencode(a_cids.join(','))+'&_source='+urlencode(this.env.source)+'&_from='+(this.env.action ? this.env.action : '')+qs); 
  • trunk/roundcubemail/program/localization/en_US/messages.inc

    r3425 r3457  
    9898$messages['contactaddedtogroup'] = 'Successfully added the contacts to this group'; 
    9999$messages['contactremovedfromgroup'] = 'Successfully remove contacts from this group'; 
     100 
    100101$messages['importwait'] = 'Importing, please wait...'; 
    101102$messages['importerror'] = 'Import failed! The uploaded file is not a valid vCard file.'; 
  • trunk/roundcubemail/program/steps/addressbook/groups.inc

    r3448 r3457  
    2626} 
    2727 
    28 if ($RCMAIL->action == 'group-addmember') { 
    29   if (($gid = get_input_value('_gid', RCUBE_INPUT_POST)) && ($ids = get_input_value('_cid', RCUBE_INPUT_POST))) 
    30   if ($CONTACTS->add_to_group($gid, $ids)) 
    31     $OUTPUT->show_message('contactaddedtogroup'); 
    32   //else 
    33   //  $OUTPUT->show_message('erroraddingcontact', 'warning'); 
     28$source = get_input_value('_source', RCUBE_INPUT_GPC); 
     29 
     30if ($RCMAIL->action == 'group-addmembers') { 
     31  if (($gid = get_input_value('_gid', RCUBE_INPUT_POST)) && ($ids = get_input_value('_cid', RCUBE_INPUT_POST))) { 
     32    $plugin = $RCMAIL->plugins->exec_hook('group_addmember', array('group_id' => $gid, 'ids' => $ids, 'source' => $source)); 
     33     
     34    if (!$plugin['abort'] && $CONTACTS->add_to_group($gid, $plugin['ids'])) 
     35      $OUTPUT->show_message('contactaddedtogroup'); 
     36    else if ($plugin['message']) 
     37      $OUTPUT->show_message($plugin['message'], 'warning'); 
     38  } 
    3439} 
    3540 
    36 else if ($RCMAIL->action == 'group-delmember') { 
    37   if (($gid = get_input_value('_gid', RCUBE_INPUT_POST)) && ($ids = get_input_value('_cid', RCUBE_INPUT_POST))) 
    38   if ($CONTACTS->remove_from_group($gid, $ids)) 
    39     $OUTPUT->show_message('contactremovedfromgroup'); 
    40   //else 
    41   //  $OUTPUT->show_message('erroraddingcontact', 'warning'); 
     41else if ($RCMAIL->action == 'group-delmembers') { 
     42  if (($gid = get_input_value('_gid', RCUBE_INPUT_POST)) && ($ids = get_input_value('_cid', RCUBE_INPUT_POST))) { 
     43    $plugin = $RCMAIL->plugins->exec_hook('group_delmembers', array('group_id' => $gid, 'ids' => $ids, 'source' => $source)); 
     44    $ids = $plugin['ids']; 
     45     
     46    if (!$plugin['abort'] && $CONTACTS->remove_from_group($gid, $ids)) 
     47      $OUTPUT->show_message('contactremovedfromgroup'); 
     48    else if ($plugin['message']) 
     49      $OUTPUT->show_message($plugin['message'], 'warning'); 
     50  } 
    4251} 
    4352 
    4453else if ($RCMAIL->action == 'group-create') { 
    45   if (!empty($_POST['_name'])) { 
    46     $name = trim(get_input_value('_name', RCUBE_INPUT_POST)); 
    47     $created = $CONTACTS->create_group($name); 
     54  if ($name = trim(get_input_value('_name', RCUBE_INPUT_POST))) { 
     55    $plugin = $RCMAIL->plugins->exec_hook('group_create', array('name' => $name, 'source' => $source)); 
     56    if (!$plugin['abort']) 
     57      $created = $CONTACTS->create_group($plugin['name']); 
    4858  } 
    4959   
     
    5161    $OUTPUT->command('insert_contact_group', $created); 
    5262  } 
    53   else if (!$create) { 
    54     $OUTPUT->show_message('errorsaving', 'error'); 
     63  else if (!$created) { 
     64    $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'errorsaving', 'error'); 
    5565  } 
    5666} 
    5767 
    5868else if ($RCMAIL->action == 'group-rename') { 
    59   if (($gid = get_input_value('_gid', RCUBE_INPUT_POST)) && ($name = trim(get_input_value('_name', RCUBE_INPUT_POST)))) 
    60     $newname = $CONTACTS->rename_group($gid, $name); 
     69  if (($gid = get_input_value('_gid', RCUBE_INPUT_POST)) && ($name = trim(get_input_value('_name', RCUBE_INPUT_POST)))) { 
     70    $plugin = $RCMAIL->plugins->exec_hook('group_rename', array('group_id' => $gid, 'name' => $name, 'source' => $source)); 
     71    if (!$plugin['abort']) 
     72      $newname = $CONTACTS->rename_group($gid, $plugin['name']); 
     73  } 
    6174 
    6275  if ($newname && $OUTPUT->ajax_call) 
    6376    $OUTPUT->command('update_contact_group', $gid, $newname); 
    6477  else if (!$newname) 
    65     $OUTPUT->show_message('errorsaving', 'error'); 
     78    $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'errorsaving', 'error'); 
    6679} 
    6780 
    6881else if ($RCMAIL->action == 'group-delete') { 
    69   if ($gid = get_input_value('_gid', RCUBE_INPUT_POST)) 
    70     $deleted = $CONTACTS->delete_group($gid); 
     82  if ($gid = get_input_value('_gid', RCUBE_INPUT_POST)) { 
     83    $plugin = $RCMAIL->plugins->exec_hook('group_delete', array('group_id' => $gid, 'source' => $source)); 
     84    if (!$plugin['abort']) 
     85      $deleted = $CONTACTS->delete_group($gid); 
     86  } 
    7187 
    7288  if ($deleted) 
    7389    $OUTPUT->command('remove_group_item', $gid); 
    7490  else 
    75     $OUTPUT->show_message('errorsaving', 'error'); 
     91    $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'errorsaving', 'error'); 
    7692} 
    7793 
Note: See TracChangeset for help on using the changeset viewer.