Skip to content

Commit

Permalink
Revert "First pass at supporting importing/exporting contact groups v…
Browse files Browse the repository at this point in the history
…ia csv/tsv."

This is a new feature, not suitable for FW_5_2

This reverts commit 54fb5ef.
  • Loading branch information
mrubinsk committed Dec 9, 2015
1 parent 028e904 commit c9a7115
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 58 deletions.
43 changes: 2 additions & 41 deletions turba/data.php
Expand Up @@ -85,10 +85,6 @@ function _emptyAttributeFilter($var)
'jobtitle' => 'title',
'internetfreebusy' => 'freebusyUrl',

// Turba groups
'uid' => '__uid',
'members' => '__members',

// Entourage on MacOS
'Dept' => 'department',
'Work Street Address' => 'workStreet',
Expand Down Expand Up @@ -271,17 +267,9 @@ function _emptyAttributeFilter($var)

$error = false;
$imported = 0;
$contact_groups = array();
foreach ($next_step as $row) {
if ($row instanceof Horde_Icalendar_Vcard) {
$row = $driver->toHash($row);
} else {
// Check for contact groups, and defer processing until all
// other contacts are added.
if (!empty($row['__members'])) {
$contact_groups[] = $row;
continue;
}
}

/* Don't search for empty attributes. */
Expand Down Expand Up @@ -327,27 +315,6 @@ function _emptyAttributeFilter($var)
}
}
}

// Now attempt to create Turba group objects.
foreach ($contact_groups as $group) {
$attributes = $group;
unset($attributes['__members']);
$group_obj = new Turba_Object_Group($driver, $attributes);
foreach (explode(',', $group['__members']) as $uid) {
$results = $driver->search(array('__uid' => $uid));
if (count($results->objects)) {
$object = array_pop($results->objects);
$group_obj->addMember($object->getValue('__key'), $object->getSource());
}
}
// We don't actually use the group object to save to storage since
// it's not an existing group. We use it so it's responsible for
// properly formatting the __members data, which we pull out and
// place in the attributes array.
$attributes['__members'] = $group_obj->getValue('__members');
$attributes['__type'] = 'group';
$driver->add($attributes);
}
if (!$error && $imported) {
$notification->push(sprintf(_("%s file successfully imported."),
$file_types[$data->storage->get('format')]), 'horde.success');
Expand All @@ -360,14 +327,8 @@ function _emptyAttributeFilter($var)
case Horde_Data::IMPORT_MAPPED:
case Horde_Data::IMPORT_DATETIME:
foreach ($cfgSources[$data->storage->get('target')]['map'] as $field => $null) {
if ((substr($field, 0, 2) != '__' && !is_array($null)) || ($field == '__uid' || $field == '__members')) {
if ($field == '__uid') {
$app_fields['__uid'] = _("UID");
} elseif ($field == '__members') {
$app_fields['__members'] = _("Contact list members");
} else {
$app_fields[$field] = $attributes[$field]['label'];
}
if (substr($field, 0, 2) != '__' && !is_array($null)) {
$app_fields[$field] = $attributes[$field]['label'];
}
}
break;
Expand Down
19 changes: 2 additions & 17 deletions turba/lib/Application.php
Expand Up @@ -559,27 +559,12 @@ public function download(Horde_Variables $vars)
} else {
$row = array();
foreach ($fields as $field) {
if ((substr($field, 0, 2) == '__' && $field != '__members' && $field != '__uid') ||
if (substr($field, 0, 2) == '__' ||
isset($blobs[$field])) {
continue;
}
$attribute = $ob->getValue($field);
if ($field == '__members') {
if (empty($attribute)) {
$row['kind'] = '';
$row['members'] = '';
continue;
}
$row['kind'] = 'group';
$members = $ob->listMembers();
$uids = array();
foreach ($members->objects as $member) {
$uids[] = $member->getValue('__uid');
}
$row['members'] = implode(',', $uids);
} elseif ($field == '__uid') {
$row['uid'] = !empty($attribute) ? $attribute : '';
} elseif ($attributes[$field]['type'] == 'date') {
if ($attributes[$field]['type'] == 'date') {
$row[$field] = strftime('%Y-%m-%d', $attribute);
} elseif ($attributes[$field]['type'] == 'time') {
$row[$field] = strftime('%R', $attribute);
Expand Down

0 comments on commit c9a7115

Please sign in to comment.