/usr/share/horde/turba/lib/Ajax/Application/Handler/Minisearch.php is in php-horde-turba 4.1.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | <?php
/**
* Defines AJAX actions used to process Turba minisearch requests.
*
* Copyright 2012-2013 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (ASL). If you
* did not receive this file, see http://www.horde.org/licenses/apache.
*
* @author Michael Slusarz <slusarz@horde.org>
* @category Horde
* @license http://www.horde.org/licenses/apache ASL
* @package Turba
*/
class Turba_Ajax_Application_Handler_Minisearch extends Horde_Core_Ajax_Application_Handler
{
/**
* AJAX action: Return Turba minisearch information.
*
* Variables used:
* - abooks: (array) UIDs of source addressbook.
* - search: (string) Search string.
*
* @return object HTML search output in the 'html' parameter.
*/
public function minisearch()
{
global $attributes, $injector, $registry;
$ob = new stdClass;
$results = array();
$search = trim($this->vars->search);
if (!is_null($search)) {
foreach (Horde_Serialize::unserialize($this->vars->abooks, Horde_Serialize::JSON) as $val) {
try {
$res = $injector->getInstance('Turba_Factory_Driver')
->create($val)
->search(array('name' => $search));
while ($ob = $res->next()) {
if ($ob->isGroup()) {
continue;
}
foreach ($ob->getAttributes() as $k => $v) {
if (!empty($attributes[$k]['type']) &&
($attributes[$k]['type'] == 'email')) {
if (!empty($v)) {
try {
$mail_link = $registry->call('mail/compose', array(
array('to' => $v)
));
} catch (Horde_Exception $e) {
$mail_link = 'mailto:' . urlencode($v);
}
}
$link = empty($v)
? htmlspecialchars($ob->getValue('name'))
: htmlspecialchars($ob->getValue('name') . ' <' . $v . '>');
$results[] = '<li class="linedRow">' .
Horde::link(Horde::url($ob->url()), _("View Contact"), '', '_parent') .
Horde::img('contact.png', _("View Contact")) . '</a> ' .
(!empty($v) ? '<a href="' . $mail_link . '">' : '') .
$link .
(!empty($v) ? '</a>' : '') . '</li>';
break;
}
}
}
} catch (Turba_Exception $e) {}
}
}
if (count($results)) {
$ob->html = '<ul>' . implode('', $results) . '</ul>';
} elseif (is_null($search)) {
$ob->html = _("No contacts found");
}
return $ob;
}
}
|