alecpl
2010-09-25 e019f2d0f2dc2fbfa345ab5d7ae85e67bfdd76b8
program/steps/addressbook/groups.inc
@@ -4,8 +4,8 @@
 +-----------------------------------------------------------------------+
 | program/steps/addressbook/groups.inc                                  |
 |                                                                       |
 | This file is part of the RoundCube Webmail client                     |
 | Copyright (C) 2010, RoundCube Dev. - Switzerland                      |
 | This file is part of the Roundcube Webmail client                     |
 | Copyright (C) 2010, Roundcube Dev. - Switzerland                      |
 | Licensed under the GNU GPL                                            |
 |                                                                       |
 | PURPOSE:                                                              |
@@ -19,7 +19,6 @@
*/
if ($CONTACTS->readonly || !$CONTACTS->groups) {
  $OUTPUT->show_message('sourceisreadonly', 'warning');
  $OUTPUT->send();
@@ -29,9 +28,14 @@
if ($RCMAIL->action == 'group-addmembers') {
  if (($gid = get_input_value('_gid', RCUBE_INPUT_POST)) && ($ids = get_input_value('_cid', RCUBE_INPUT_POST))) {
    $plugin = $RCMAIL->plugins->exec_hook('group_addmember', array('group_id' => $gid, 'ids' => $ids, 'source' => $source));
    $plugin = $RCMAIL->plugins->exec_hook('group_addmembers', array('group_id' => $gid, 'ids' => $ids, 'source' => $source));
    
    if (!$plugin['abort'] && $CONTACTS->add_to_group($gid, $plugin['ids']))
    $CONTACTS->set_group($gid);
    $num2add = count(explode(',', $plugin['ids']));
    if (!$plugin['abort'] && ($maxnum = $RCMAIL->config->get('max_group_members', 0)) && ($CONTACTS->count()->count + $num2add > $maxnum))
      $OUTPUT->show_message('maxgroupmembersreached', 'warning', array('max' => $maxnum));
    else if (!$plugin['abort'] && $CONTACTS->add_to_group($gid, $plugin['ids']))
      $OUTPUT->show_message('contactaddedtogroup');
    else if ($plugin['message'])
      $OUTPUT->show_message($plugin['message'], 'warning');
@@ -41,9 +45,8 @@
else if ($RCMAIL->action == 'group-delmembers') {
  if (($gid = get_input_value('_gid', RCUBE_INPUT_POST)) && ($ids = get_input_value('_cid', RCUBE_INPUT_POST))) {
    $plugin = $RCMAIL->plugins->exec_hook('group_delmembers', array('group_id' => $gid, 'ids' => $ids, 'source' => $source));
    $ids = $plugin['ids'];
    
    if (!$plugin['abort'] && $CONTACTS->remove_from_group($gid, $ids))
    if (!$plugin['abort'] && $CONTACTS->remove_from_group($gid, $plugin['ids']))
      $OUTPUT->show_message('contactremovedfromgroup');
    else if ($plugin['message'])
      $OUTPUT->show_message($plugin['message'], 'warning');
@@ -58,6 +61,7 @@
  }
  
  if ($created && $OUTPUT->ajax_call) {
    $created['source'] = $source;
    $OUTPUT->command('insert_contact_group', $created);
  }
  else if (!$created) {
@@ -73,7 +77,7 @@
  }
  if ($newname && $OUTPUT->ajax_call)
    $OUTPUT->command('update_contact_group', $gid, $newname);
    $OUTPUT->command('update_contact_group', array('source' => $source, 'id' => $gid, 'name' => $newname));
  else if (!$newname)
    $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'errorsaving', 'error');
}
@@ -86,7 +90,7 @@
  }
  if ($deleted)
    $OUTPUT->command('remove_group_item', $gid);
    $OUTPUT->command('remove_group_item', array('source' => $source, 'id' => $gid));
  else
    $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'errorsaving', 'error');
}
@@ -94,4 +98,3 @@
// send response
$OUTPUT->send();
?>