/* Perform a search. */
if ($search_mode == 'duplicate') {
try {
$duplicates = $driver->searchDuplicates();
$view = new Turba_View_Duplicates($duplicates, $driver, $vars->type, $vars->dupe);
$page_output->addScriptFile('tables.js', 'horde');
} catch (Exception $e) {
$notification->push($e);
}
} else {
try {
if ($search_mode == 'basic' && ($results = $driver->search($criteria, null, 'OR')) || $search_mode == 'advanced' && ($results = $driver->search($criteria))) {
/* Read the columns to display from the preferences. */
$sources = Turba::getColumns();
$columns = isset($sources[$source]) ? $sources[$source] : array();
$results->sort(Turba::getPreferredSortOrder());
$view = new Turba_View_List($results, null, $columns);
$view->setType('search');
} else {
$notification->push(_("Failed to search the address book"), 'horde.error');
}
} catch (Turba_Exception $e) {
$notification->push($e, 'horde.error');
}
}
}
}
/* Build search mode tabs. */
$sUrl = Horde::url('search.php');
$tabs = new Horde_Core_Ui_Tabs('search_mode', $vars);
$tabs->addTab(_("Basic Search"), $sUrl, 'basic');