]> git.donarmstrong.com Git - roundcube.git/blobdiff - program/steps/addressbook/save.inc
Fix symlink mess
[roundcube.git] / program / steps / addressbook / save.inc
index ef4387afd282684984ceb7d64b335f349a7a037a..6ce9bd43e1879e72b97d28ec869c229c81bdbd83 100644 (file)
@@ -15,7 +15,7 @@
  | Author: Thomas Bruederli <roundcube@gmail.com>                        |
  +-----------------------------------------------------------------------+
 
- $Id: save.inc 5130 2011-08-25 08:30:01Z alec $
+ $Id: save.inc 5873 2012-02-11 13:50:04Z thomasb $
 
 */
 
@@ -50,10 +50,12 @@ foreach ($GLOBALS['CONTACT_COLTYPES'] as $col => $colprop) {
       foreach ((array)$vals as $i => $val)
         $values[$i][$childcol] = $val;
     }
-    $subtypes = get_input_value('_subtype_' . $col, RCUBE_INPUT_POST);
-    foreach ($subtypes as $i => $subtype)
+    $subtypes = isset($_REQUEST['_subtype_' . $col]) ? (array)get_input_value('_subtype_' . $col, RCUBE_INPUT_POST) : array('');
+    foreach ($subtypes as $i => $subtype) {
+      $suffix = $subtype ? ':'.$subtype : '';
       if ($values[$i])
-        $a_record[$col.':'.$subtype][] = $values[$i];
+        $a_record[$col.$suffix][] = $values[$i];
+     }
   }
   // assign values and subtypes
   else if (is_array($_POST[$fname])) {
@@ -79,8 +81,8 @@ if (empty($a_record['name'])) {
 
 // do input checks (delegated to $CONTACTS instance)
 if (!$CONTACTS->validate($a_record)) {
-    $err = (array)$CONTACTS->get_error() + array('message' => 'formincomplete', 'type' => 'warning');
-    $OUTPUT->show_message($err['message'], $err['type']);
+    $err = (array)$CONTACTS->get_error();
+    $OUTPUT->show_message($err['message'] ? $err['message'] : 'formincomplete', 'warning');
     $GLOBALS['EDIT_RECORD'] = $a_record;  // store submitted data to be used in edit form
     rcmail_overwrite_action($return_action);
     return;
@@ -130,8 +132,7 @@ if (!empty($cid))
     $a_js_cols = array();
     $record = $CONTACTS->get_record($newcid ? $newcid : $cid, true);
     $record['email'] = reset($CONTACTS->get_col_values('email', $record, true));
-    if (empty($record['name']))
-      $record['name']  = rcube_addressbook::compose_display_name($record, true);
+    $record['name']  = rcube_addressbook::compose_list_name($record);
 
     foreach (array('name', 'email') as $col)
       $a_js_cols[] = Q((string)$record[$col]);
@@ -162,7 +163,7 @@ else {
   // show notice if existing contacts with same e-mail are found
   $existing = false;
   foreach ($CONTACTS->get_col_values('email', $a_record, true) as $email) {
-      if ($email && ($res = $CONTACTS->search('email', $email, false, false, true)) && $res->count) {
+      if ($email && ($res = $CONTACTS->search('email', $email, 1, false, true)) && $res->count) {
           $OUTPUT->show_message('contactexists', 'notice', null, false);
           break;
       }