steffen: server/kolab-horde-fbview/kolab-horde-fbview/fbview/turba COPYING, NONE, 1.1 README, NONE, 1.1 addlink.php, NONE, 1.1 browse.php, NONE, 1.1 display.php, NONE, 1.1 index.php, NONE, 1.1 minisearch.php, NONE, 1.1 miniwindow.php, NONE, 1.1 search.php, NONE, 1.1 test.php, NONE, 1.1 vcard.php, NONE, 1.1

cvs at intevation.de cvs at intevation.de
Mon Oct 31 12:43:37 CET 2005


Author: steffen

Update of /kolabrepository/server/kolab-horde-fbview/kolab-horde-fbview/fbview/turba
In directory doto:/tmp/cvs-serv18388/kolab-horde-fbview/kolab-horde-fbview/fbview/turba

Added Files:
	COPYING README addlink.php browse.php display.php index.php 
	minisearch.php miniwindow.php search.php test.php vcard.php 
Log Message:
Fbview in separate package

--- NEW FILE: COPYING ---
Version 1.0

Copyright (c) 2000-2002 The Horde Project. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

3. The end-user documentation included with the redistribution, if
any, must include the following acknowledgment:

   "This product includes software developed by the Horde Project
    (http://www.horde.org/)."

Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.

4. The names "Turba", "Horde" and "The Horde Project" must not be used
to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
core at horde.org.

5. Products derived from this software may not be called "Turba" or
"Horde", nor may "Turba" or "Horde" appear in their name, without
prior written permission of the Horde Project.

THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

This software consists of voluntary contributions made by many
individuals on behalf of the Horde Project. For more information on
the Horde Project, please see <http://www.horde.org/>.

----------
$Horde: turba/COPYING,v 1.4 2002/01/16 16:10:03 jan Exp $
--- NEW FILE: README ---
Turba
Version 2.0

What is Turba?
--------------

Turba is the Horde contact management application, designed to be
integrated with other Horde applications to provide a unified
interface to contact management throughout the Horde suite.

This software is OSI Certified Open Source Software.
OSI Certified is a certification mark of the Open Source Initiative.


Obtaining Turba
---------------

Further information on Turba and the latest version can be obtained at

  http://www.horde.org/turba/


Documentation
-------------

The following documentation is available in the Turba distribution:

README         - This file
COPYING        - Copyright and license information
docs/CHANGES   - List of changes by release
docs/CREDITS   - Who developed this
docs/INSTALL   - Installation instructions

Installation
------------

Instructions for installing Turba can be found in the file INSTALL
in the docs/ directory of the Turba distribution.


Assistance
----------

If you encounter problems with Turba, help is available! 

The Horde Frequently Asked Questions List (FAQ), available on the Web
at
 
  http://www.horde.org/faq/

The Horde Project runs a number of mailing lists, for individual
applications and for issues relating to the project as a whole.
Information, archives, and subscription information can be found at

  http://www.horde.org/mail/

Lastly, Horde developers, contributors and users also make occasional
appearances on IRC, on the channel #horde on the freenode Network
(irc.freenode.net).


Licensing
---------

For licensing and copyright information, please see the file
COPYING in the Turba distribution.

Thanks,

The Turba team
turba at lists.horde.org

$Horde: turba/README,v 1.11 2004/03/06 15:47:00 jan Exp $

--- NEW FILE: addlink.php ---
<?php
/**
 * $Horde: turba/addlink.php,v 1.16 2004/04/07 14:43:52 chuck Exp $
 *
 * Copyright 2000-2004 Chuck Hagenbuch <chuck at horde.org>
 *
 * See the enclosed file COPYING for license information (GPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
 */

define('TURBA_BASE', dirname(__FILE__));
require_once TURBA_BASE . '/lib/base.php';
require_once 'Horde/Menu.php';

$return_url = Util::getFormData('url');
$link_type = Util::getFormData('link_type');
$reverse = (substr($link_type, -8) == '/reverse') ? '/reverse' : '';
if (!empty($reverse)) {
    $link_type = substr($link_type, 0, -8);
}
$from_application = Util::getFormData('from_application');
$from_parameters = @unserialize(Util::getFormData('from_parameters'));
$to_application = Util::getFormData('to_application');

switch (Util::getFormData('actionID')) {
case 'addlink_add':
    if (!empty($to_application)) {
        require_once 'Horde/Links.php';
        $links = &Horde_Links::singleton($registry->getApp());

        $to_parameters = @unserialize(Util::getFormData('to_parameters'));
       
        if (empty($reverse)) {
            $link_data = array('to_params' => $to_parameters, 
                               'from_params' => $from_parameters, 
                               'link_params' => array('link_type' => $link_type,
                                                      'to_application' => $to_application,
                                                      'from_application' => $from_application));
        } else {
            // Switch 'to' and 'from' for reverse links.
            $link_data = array('to_params' => $from_parameters, 
                               'from_params' => $to_parameters, 
                               'link_params' => array('link_type' => $link_type,
                                                      'to_application' => $from_application,
                                                      'from_application' => $to_application));
        }
        $status = $links->addLink($link_data);

        if (is_a($status, 'PEAR_Error')) {
            $notification->push($status, 'horde.error');
        } elseif ($registry->hasMethod($to_application . '/getLinkSummary')) {
            $notification->push(sprintf(_("Added a %s link to %s."), $link_type,
                                        $registry->call($to_application . '/getLinkSummary', array($link_data))), 'horde.success');
        } else {
            $notification->push(_("Link added."), 'horde.success');
        }

        header('Location: ' . $return_url);
        exit;
    }
    break;

case 'addlink_cancel':
    $notification->push(_("Link canceled."), 'horde.message');
    header('Location: ' . $return_url);
    exit;
}

/* Get the lists of address books through the API. */
$source_list = $registry->call('contacts/sources');

// If we self-submitted, use that source. Otherwise, choose a good
// source.
if (!($source = Util::getFormData('source'))) {
    if ($prefs->getValue('add_source')) {
        // The most likely personal address book is the one we add to.
        $source = $prefs->getValue('add_source');
    } elseif ($prefs->getValue('search_sources')) {
        // If we can't/don't add, do we search?  If so take the first.
        $search_sources = $prefs->getValue('search_sources');
        $source = $search_sources[0];
    }
}
if (empty($source) || !isset($source_list[$source])) {
    $source = key($source_list);
}

/* Get the search as submitted (defaults to '' which should list everyone). */
$search = Util::getFormData('search');
$apiargs = array();
$apiargs['addresses'] = array($search);
$apiargs['addressbooks'] = array($source);
$apiargs['fields'] = array();

if ($search_fields_pref = $prefs->getValue('search_fields')) {
    foreach (explode("\n", $search_fields_pref) as $s) {
        $s = trim($s);
        $s = explode("\t", $s);
        if (!empty($s[0]) && ($s[0] == $source)) {
            $apiargs['fields'][array_shift($s)] = $s;
            break;
        }
    }
}

$results = $registry->call('contacts/search', $apiargs);

/* The results list returns an array for each source searched - at
   least that's how it looks to me. Make it all one array instead. */
$addresses = array();
if (!PEAR::isError($results)) {
    foreach ($results as $r) {
        $addresses = array_merge($addresses, $r);
    }
}

/* If self-submitted, preserve the currently selected users encoded by
   javascript to pass as value|text. */
$selected_addresses = array();
foreach ($_GET as $key => $value) {
    if (substr($key, 0, 2) == 'sa') {
        $a = explode('|', $value);
        $selected_addresses[$a[0]] = $a[1];
    }
}

/* Set the default list display (name or email). */
$display = Util::getFormData('display', 'name');

/* Set the to_application to be included in the form. */
$to_application = $registry->getParam('provides');
if (is_array($to_application)) {
    $to_application = $to_application[0];
}

/* Display the form. */
$tabindex = 1;
$title = _("Contact List");
require TURBA_TEMPLATES . '/common-header.inc';
require TURBA_TEMPLATES . '/addlink/menu.inc';
$notification->notify(array('listeners' => 'status'));
require TURBA_TEMPLATES . '/addlink/contacts.inc';
require $registry->getParam('templates', 'horde') . '/common-footer.inc';

--- NEW FILE: browse.php ---
<?php
/**
 * $Horde: turba/browse.php,v 1.64 2004/04/07 14:43:52 chuck Exp $
 *
 * Turba: Copyright 2000-2004 Charles J. Hagenbuch <chuck at horde.org>
 *
 * You should have received a copy of the GNU Public
 * License along with this package; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

@define('TURBA_BASE', dirname(__FILE__));
require_once TURBA_BASE . '/lib/base.php';
require_once TURBA_BASE . '/lib/Source.php';
require_once TURBA_BASE . '/lib/List.php';
require TURBA_BASE . '/config/attributes.php';

/* Sort out the sorting values. */
if (($sortby = Util::getFormData('sortby')) !== null) {
    if ($sortby == 'name') {
        if ($prefs->getValue('name_format') == 'first_last') {
            $sortby = 'name';
        } else {
            $sortby = 'lastname';
        }
    }
    $prefs->setValue('sortby', $sortby);
}
if (($sortdir = Util::getFormData('sortdir')) !== null) {
    $prefs->setValue('sortdir', $sortdir);
}

$title = _("Address Book Listing");

/* Build the directory sources select widget. */
$source = Util::getFormData('source', $prefs->getValue('default_dir'));
$source_options = '';
$add_source_options = '';
$source_count = 0;
foreach ($cfgSources as $key => $curSource) {
    if (!empty($curSource['export'])) {
        $selected = ($key == $source) ? ' selected="selected"' : '';
        $source_options .= '<option value="' . $key . '" ' . $selected;
        $source_options .= '>' . htmlspecialchars($curSource['title']) . '</option>';
        if ($key != $source && empty($curSource['readonly']) || (isset($curSource['admin']) && in_array(Auth::getAuth(), $curSource['admin']))) {
            $add_source_options .= '<option value="' . $key . '">' . htmlspecialchars($curSource['title']) . '</option>';
        }
        $source_count++;
        if (empty($source)) {
            $source = $key;
        }
    }
}

if ($source_count == 0) {
    $notification->push(_("There are no browseable address books."), 'horde.warning');
} else {
    $driver = &Turba_Source::singleton($source, $cfgSources[$source]);
    if (is_a($driver, 'PEAR_Error')) {
        $notification->push(sprintf(_("Failed to access the specified address book: %s"), $driver->getMessage()), 'horde.error');
        unset($driver);
    }
}

if (isset($driver)) {
    $actionID = Util::getFormData('actionID');

    /* Run through the action handlers. */
    switch ($actionID) {
    case 'delete':
        /* Remove a contact from a list. */
        $keys = Util::getFormData('objectkeys');
        if (is_array($keys)) {
            $key = Util::getFormData('key', false);
            if ($key && $key != '**search') {
                /* We are removing a contact from a list. */
                $list = $driver->getObject($key);
                foreach ($keys as $sourceKey) {
                    list($source, $objectKey) = explode(':', $sourceKey, 2);
                    if (!$list->removeMember($driver->getObject($objectKey))) {
                        $notification->push(_("There was an error removing this object."), 'horde.error');
                    } else {
                        $notification->push(_("Contact removed from list."), 'horde.success');
                    }
                }
            } else {
                /* We are deleting an object. */
                foreach ($keys as $sourceKey) {
                    list($source, $objectKey) = explode(':', $sourceKey, 2);
                    if (!$driver->removeObject($objectKey)) {
                        $notification->push(_("There was an error deleting this object."), 'horde.error');
                    }
                }
            }

            /* Remove the objects from search results too. */
            if (!empty($_SESSION['turba_search_results'])) {
                require_once TURBA_BASE . '/lib/Object.php';
                $list = Turba_List::unserialize($_SESSION['turba_search_results']);
                foreach ($keys as $sourceKey) {
                    list($source, $objectKey) = explode(':', $sourceKey, 2);
                    $list->remove($objectKey);
                }
                $_SESSION['turba_search_results'] = $list->serialize();
            }
        }
        break;

    case 'move':
    case 'copy':
        $keys = Util::getFormData('objectkeys');
        if (is_array($keys) && count($keys)) {
            // If we have data, try loading the target address book
            // driver.
            $targetSource = Util::getFormData('targetAddressbook');
            $targetDriver = &Turba_Source::singleton($targetSource, $cfgSources[$targetSource]);

            if (is_a($targetDriver, 'PEAR_Error')) {
                $notification->push(sprintf(_("Failed to access the specified address book: %s"), $targetDriver->getMessage()), 'horde.error');
            } else {
                foreach ($keys as $sourceKey) {
                    // Split up the key into source and object ids.
                    list($source, $objectKey) = explode(':', $sourceKey, 2);

                    // Ignore this entry if the target is the same as
                    // the source.
                    if ($source == $targetDriver->name) {
                        continue;
                    }

                    // Try and load the driver for the source.
                    $sourceDriver = &Turba_Source::singleton($source, $cfgSources[$source]);
                    if (is_a($sourceDriver, 'PEAR_Error')) {
                        $notification->push(sprintf(_("Failed to access the specified address book: %s"), $sourceDriver->getMessage()), 'horde.error');
                    } else {
                        // Get the object.
                        $object = $sourceDriver->getObject($objectKey);
                        if (is_a($object, 'PEAR_Error')) {
                            $notification->push(sprintf(_("Failed to find object to be added: %s"), $object->getMessage()), 'horde.error');
                        } else {
                            // Try adding to the target.
                            $result = $targetDriver->addObject($object->getAttributes());
                            if (is_a($result, 'PEAR_Error')) {
                                $notification->push(sprintf(_("Failed to add %s to %s: %s"), $object->getValue('name'), $targetDriver->title, $result->getMessage()), 'horde.error');
                            } else {
                                $notification->push(sprintf(_("Successfully added %s to %s"), $object->getValue('name'), $targetDriver->title), 'horde.success');

                                // If we're moving objects, and we
                                // succeeded, delete it from the
                                // original source now.
                                if ($actionID == 'move') {
                                    if (!$sourceDriver->removeObject($objectKey)) {
                                        $notification->push(sprintf(_("There was an error deleting %s from the source address book."), $object->getValue('name')), 'horde.error');
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        break;

    case 'add':
        /* Add a contact to a list. */
        $keys = Util::getFormData('objectkeys');
        $targetKey = Util::getFormData('targetList');
        if (empty($targetKey)) {
            break;
        }

        if (!Util::getFormData('targetNew')) {
            $target = $driver->getObject($targetKey);
        }

        if (!empty($target) && is_object($target) && $target->isGroup()) {
            /* Adding contact to an existing list */
            if (is_array($keys)) {
                foreach ($keys as $sourceKey) {
                    list($source, $objectKey) = explode(':', $sourceKey, 2);
                    $target->addMember($driver->getObject($objectKey));
                }
                $target->store();
            }
        } else {
            /* Adding contact to a new list. */
            $newList = array();
            $newList['__owner'] = Auth::getAuth();
            $newList['__type'] = 'Group';
            $newList['name'] = $targetKey;

            $targetKey = $driver->addObject($newList);
            $target = $driver->getObject($targetKey);
            if (!empty($target) && is_object($target) && $target->isGroup()) {
                if (is_array($keys)) {
                    foreach ($keys as $sourceKey) {
                        list($source, $objectKey) = explode(':', $sourceKey, 2);
                        $target->addMember($driver->getObject($objectKey));
                    }
                    $target->store();
                }
            } else {
                $notification->push(_("There was an error creating a new list."), 'horde.error');
            }
        }
        break;
    }
}

$templates = array();
if (isset($driver)) {
    $templates[] = '/browse/javascript.inc';

    /* Read the columns to display from the preferences. */
    $sources = Turba::string2Columns($prefs->getValue('columns'));
    $columns = isset($sources[$source]) ? $sources[$source] : array();
    $width = floor(90 / (count($columns) + 1));

    /* Determine the name of the column to sort by. */
    $sortcolumn = ($prefs->getValue('sortby') == 0 ||
                   !isset($columns[$prefs->getValue('sortby') - 1])) ?
        (($prefs->getValue('name_format') == 'first_last') ? 'name' : 'lastname') : $columns[$prefs->getValue('sortby') - 1];

    /* Create list of lists for Add to. */
    $addToList = array();
    if (!empty($cfgSources[$source]['map']['__type'])) {
        $listList = $driver->search(array('__type' => 'Group'));
        $listList->reset();
        while ($listObject = $listList->next()) {
            $addToList[] = array('name' => $listObject->getValue('name'), 'key' => $listObject->getValue('__key'));
        }
    }

    if (isset($_SESSION['turba_search_results']) &&
        (Util::getFormData('key') == '**search')) {
        /* We are displaying some search results. */
        $results = Turba_List::unserialize($_SESSION['turba_search_results']);
        $results->sort($sortcolumn, $prefs->getValue('sortdir'));

        $templates[] = '/browse/search.inc';

        if ($_SESSION['turba_search_mode'] == 'advanced') {
            $map = $driver->getCriteria();
            $templates[] = '/browse/search_criteria.inc';
        }

        $templates[] = '/browse/header.inc';
        $templates[] = '/browse/actions.inc';
        $templates[] = '/browse/column_headers.inc';

        $title =_("Search Results");
        $listType = 'search';

        if ($_SESSION['turba_search_mode'] == 'basic') {
            $notification->push('document.directory_search.val.focus();', 'javascript');
        } else {
            $notification->push('document.directory_search.name.focus();', 'javascript');
        }

        require_once TURBA_BASE . '/lib/ListView.php';
        $display = &new Turba_ListView($results, TURBA_TEMPLATES . '/browse/contactrow.inc');
    } elseif (Util::getFormData('key')) {
        /* We are displaying the contents of a list. */
        $list = $driver->getObject(Util::getFormData('key'));
        if (isset($list) && is_object($list) && !is_a($list, 'PEAR_Error') && $list->isGroup()) {
            $title = sprintf(_("Contacts in list: %s"), $list->getValue('name'));
            $templates[] = '/browse/header.inc';

            /* Show List Members. */
            if (!is_object($results = $list->listMembers($sortcolumn, $prefs->getValue('sortdir')))) {
                $notification->push(_("Failed to browse list"), 'horde.error');
            } else {
                $listType = 'list';
                $templates[] = '/browse/actions.inc';
                $templates[] = '/browse/column_headers.inc';

                require_once TURBA_BASE . '/lib/ListView.php';
                $display = &new Turba_ListView($results, TURBA_TEMPLATES . '/browse/contactrow.inc');
            }
        } else {
            $notification->push(_("There was an error displaying the select List"), 'horde.error');
        }
    } else {
        /* We are displaying the contents of the address book. */
        if ($source_count > 1) {
            $templates[] = '/browse/select.inc';
        }
        $title = sprintf(_("Contents of %s"), $cfgSources[$source]['title']);
        $templates[] = '/browse/header.inc';
        if (Util::getFormData('show', 'all') == 'contacts') {
            /* Show Contacts. */
            $results = $driver->search(array('__type' => 'Object'), $sortcolumn, 'AND', $prefs->getValue('sortdir'));
        } elseif (Util::getFormData('show', 'all') == 'lists') {
            /* Show Lists. */
            $results = $driver->search(array('__type' => 'Group'), $sortcolumn, 'AND', $prefs->getValue('sortdir'));
        } else {
            /* Show All. */
            $results = $driver->search(array(), $sortcolumn, 'AND', $prefs->getValue('sortdir'));
        }

        if (!is_object($results)) {
            $notification->push(_("Failed to browse the directory"), 'horde.error');
        } else {
            $listType = 'directory';
            $templates[] = '/browse/actions.inc';
            $templates[] = '/browse/column_headers.inc';

            require_once TURBA_BASE . '/lib/ListView.php';
            $display = &new Turba_ListView($results, TURBA_TEMPLATES . '/browse/contactrow.inc');
        }
    }
} else {
    $templates[] = '/browse/select.inc';
    $templates[] = '/browse/header.inc';
}

require TURBA_TEMPLATES . '/common-header.inc';
Turba::menu();

foreach ($templates as $template) {
    require TURBA_TEMPLATES . $template;
}

$footer = 'footer.inc';

if (isset($display) && is_object($display)) {
    require_once 'Horde/UI/Pager.php';
    require_once 'Horde/Variables.php';

    if (!Util::getFormData('source') == '') {
        $urlSource = Util::getFormData('source');
    } else {
        $urlSource = $source;
    }
    $viewurl = Util::addParameter('browse.php', array(
        'sortby' => $sortby,
        'sortdir' => $sortdir,
        'key' => Util::getFormData('key'),
        'source' => $urlSource
    ));

    if (Util::getFormData('key') == '**search') {
        $page = Util::getFormData('page', 0);
        $numitem = $results->count();
        $maxpage = $prefs->getValue('maxpage');
        $perpage = $prefs->getValue('perpage');

        $min = $page * $perpage;
        while ($min > $numitem) {
            $page--;
            $min = $page * $perpage;
        }
        $max = $min + $perpage;

        $start = ($page * $perpage) + 1;
        $end = min($numitem, $start + $perpage - 1);

        $numDisplayed = $display->display($min, $max);

        $vars = &Variables::getDefaultVariables();
        $pager = &new Horde_UI_Pager('page', $vars, array('num' => $numDisplayed,
                                                          'url' => $viewurl,
                                                          'page_count' => $maxpage,
                                                          'perpage' => $perpage));
    } else {
        $page = Util::getFormData('page', '*');
        if (empty($page) || !preg_match('/^[A-Za-z*]$/', $page)) {
            $page = '*';
        }

        $display->displayAlpha($page);
        $numDisplayed = $results->count();
        $footer = 'footerAlpha.inc';
    }

    require TURBA_TEMPLATES . '/browse/column_footers.inc';
}

require TURBA_TEMPLATES . '/browse/' . $footer;
require $registry->getParam('templates', 'horde') . '/common-footer.inc';

--- NEW FILE: display.php ---
<?php
/**
 * $Horde: turba/display.php,v 1.46 2004/04/07 14:43:52 chuck Exp $
 *
 * Copyright 2000-2004 Charles J. Hagenbuch <chuck at horde.org>
 *
 * See the enclosed file COPYING for license information (GPL). If you did not
 * receive this file, see http://www.fsf.org/copyleft/gpl.html.
 */

define('TURBA_BASE', dirname(__FILE__));
require_once TURBA_BASE . '/lib/base.php';
require_once 'Horde/Form.php';
require_once 'Horde/Links.php';
require_once TURBA_BASE . '/lib/Renderer.php';
require_once TURBA_BASE . '/lib/Source.php';
require_once TURBA_BASE . '/lib/ObjectView.php';
require_once 'Horde/Variables.php';

$links = &Horde_Links::singleton($registry->getApp());
$renderer = &new Turba_Renderer();
$vars = &Variables::getDefaultVariables();

$source = $vars->get('source');
if (!isset($cfgSources[$source])) {
    $notification->push(_("The contact you requested does not exist."));
    header('Location: ' . Horde::applicationUrl($prefs->getValue('initial_page'), true));
    exit;
}

$driver = &Turba_Source::singleton($source, $cfgSources[$source]);

/* Get the form object. */
$form = &Horde_Form::singleton('', $vars);
$form->setButtons(_("Save"), true);
$form->addHidden('', 'url', 'text', false);
$form->addHidden('', 'source', 'text', true);
$form->addHidden('', 'key', 'text', false);

/* Set the contact from the key requested. */
$key = $vars->get('key');
$object = $driver->getObject($key);
if (is_a($object, 'PEAR_Error')) {
    $notification->push($object->getMessage(), 'horde.error');
    header('Location: ' . Horde::applicationUrl($prefs->getValue('initial_page'), true));
    exit;
}

/* Check permissions on this contact. */
$readonly = false;
if (!Turba::checkPermissions($object, 'object', PERMS_READ)) {
    $notification->push(_("You do not have permission to view this contact."), 'horde.error');
    header('Location: ' . Horde::applicationUrl($prefs->getValue('initial_page'), true));
    exit;
}

$renderer->setObject($object);
$view = &new Turba_ObjectView($object);

$vars = array();
/* Get the values through the AbstractObject class. */
foreach ($object->source->getCriteria() as $info_key => $info_val) {
    $vars[$info_key] = $object->getValue($info_key);
}

/* Get the contact's history. */
$history = &Horde_History::singleton();
$log = $history->getHistory($driver->getGUID($key));
foreach ($log->getData() as $entry) {
    switch ($entry['action']) {
    case 'add':
        $view->set('created', true);
        $vars['__created'] = strftime($prefs->getValue('date_format'), $entry['ts']) . ' ' . date($prefs->getValue('twentyFour') ? 'G:i' : 'g:i a', $entry['ts']);
        break;

    case 'modify':
        $view->set('modified', true);
        $vars['__modified'] = strftime($prefs->getValue('date_format'), $entry['ts']) . ' ' . date($prefs->getValue('twentyFour') ? 'G:i' : 'g:i a', $entry['ts']);
        break;
    }
}

$view->setupForm($form);

$vars = &new Variables(array('object' => $vars));
if ($title = $vars->get('object[name]')) {
    $form->setTitle($title);
}

require TURBA_TEMPLATES . '/common-header.inc';
Turba::menu();
$form->renderInactive($renderer, $vars);
if ($links->listLinkTypes()) {
    $links->viewLinks(array('source' => $source,
                            'id' => $key));
}
require $registry->getParam('templates', 'horde') . '/common-footer.inc';

--- NEW FILE: index.php ---
<?php
/**
 * $Horde: turba/index.php,v 1.27 2004/04/07 14:43:52 chuck Exp $
 *
 * Copyright 2000-2004 Charles J. Hagenbuch <chuck at horde.org>
 *
 * See the enclosed file COPYING for license information (GPL).  If you
 * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
 */

@define('TURBA_BASE', dirname(__FILE__));
$turba_configured = (@is_readable(TURBA_BASE . '/config/conf.php') &&
                     @is_readable(TURBA_BASE . '/config/attributes.php') &&
                     @is_readable(TURBA_BASE . '/config/html.php') &&
                     @is_readable(TURBA_BASE . '/config/prefs.php') &&
                     @is_readable(TURBA_BASE . '/config/sources.php'));

if (!$turba_configured) {
    require TURBA_BASE . '/../lib/Test.php';
    Horde_Test::configFilesMissing('Turba', TURBA_BASE,
        array('conf.php', 'html.php', 'prefs.php', 'sources.php'),
        array('attributes.php' => 'This file defines the Turba global attribute names and types - names, email addresses, etc.'));
}

require_once TURBA_BASE . '/lib/base.php';
require TURBA_BASE . '/' . $prefs->getValue('initial_page');

--- NEW FILE: minisearch.php ---
<?php
/**
 * $Horde: turba/minisearch.php,v 1.12 2004/02/25 21:21:37 chuck Exp $
 *
 * Copyright 2000-2004 Charles J. Hagenbuch <chuck at horde.org>
 *
 * See the enclosed file COPYING for license information (GPL). If you did not
 * receive this file, see http://www.fsf.org/copyleft/gpl.html.
 */

@define('TURBA_BASE', dirname(__FILE__));
require_once TURBA_BASE . '/lib/base.php';
require_once TURBA_BASE . '/lib/Source.php';
require TURBA_BASE . '/config/attributes.php';

$search = Util::getFormData('search');
$results = array();

// Make sure we have a source
$source = Util::getFormData('source');
if (!isset($source) && isset($cfgSources) && is_array($cfgSources) && count($cfgSources) > 0) {
    $source = $prefs->getValue('default_dir');
}
if (!isset($cfgSources[$source])) {
    reset($cfgSources);
    $source = key($cfgSources);
}

// Do the search if we have one
if (!is_null($search)) {
    $driver = &Turba_Source::singleton($source, $cfgSources[$source]);
    if (!is_a($driver, 'PEAR_Error')) {
        $criteria['name'] = trim($search);
        $res = $driver->search($criteria, 'lastname', 'OR');
        if (is_a($res, 'Turba_List')) {
            while ($ob = $res->next()) {
                if ($ob->isGroup()) {
                    continue;
                }
                $att = $ob->getAttributes();
                foreach ($att as $key => $value) {
                    if (!empty($attributes[$key]['type']) && $attributes[$key]['type'] == 'email') {
                        $results[] = array('name' => $att['name'],
                                           'email' => $value,
                                           'source' => $source,
                                           'key' => $att['__key']
                                           );
                        break;
                    }
                }
            }
        }
    }
}

$bodyClass = 'summary';
require TURBA_TEMPLATES . '/common-header.inc';

?>
<script language="JavaScript" type="text/javascript">
<!--
window.setTimeout('var status = window.parent.document.getElementById(\'turba_minisearch_searching\'); status.style.visibility = \'hidden\'', 10);
window.parent.busyExpanding = false;
//--//-->
</script>
<?php
if (count($results)) {
    echo '<table border="0" width="100%"><tr><td class="control"><b>' . _("Search Results") . ':</b></td></tr>';

    $i = 0;
    foreach ($results as $contact) {
        $url = 'display.php';
        $url = Util::addParameter($url, 'source', $contact['source']);
        $url = Util::addParameter($url, 'key', $contact['key']);

        echo '<tr><td class="item' . ($i++ % 2) . '">';
        echo Horde::link(Horde::applicationUrl($url), _("View Contact"), '', '_parent') . Horde::img('turba.gif', _("View Contact")) . "</a>  ";

        $mail_link = $GLOBALS['registry']->call('mail/compose', array(array('to' => addslashes($contact['email']))));
        if (is_a($mail_link, 'PEAR_Error')) {
            $mail_link = 'mailto:' . urlencode($contact['email']);
        }

        echo '<a href="' . $mail_link . '" target="_parent">' . htmlspecialchars($contact['name'] . " <" . $contact['email'] . ">") . '</a></td></tr>';
    }
    echo '</table>';
} elseif (!is_null($search)) {
    echo _("No contacts found");
}
?>
</body>
</html>

--- NEW FILE: miniwindow.php ---
<?php
/*
 * $Horde: turba/miniwindow.php,v 1.7 2004/04/07 14:43:52 chuck Exp $
 *
 * Copyright 2002-2004 Charles J. Hagenbuch <chuck at horde.org>
 *
 * See the enclosed file COPYING for license information (GPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
 */

define('TURBA_BASE', dirname(__FILE__));
require_once TURBA_BASE . '/lib/base.php';

if (Util::getFormData('menu')) {
    require_once 'Horde/Menu.php';
    require TURBA_TEMPLATES . '/common-header.inc';
    require TURBA_TEMPLATES . '/miniwindow/menu.inc';

    /* Include the JavaScript for the help system (if enabled). */
    if ($conf['user']['online_help'] && $browser->hasFeature('javascript')) {
        Help::javascript();
    }

    require $registry->getParam('templates', 'horde') . '/common-footer.inc';
} else {
    require TURBA_TEMPLATES . '/miniwindow/frames.inc';
}

--- NEW FILE: search.php ---
<?php
/**
 * $Horde: turba/search.php,v 1.89 2004/02/25 21:21:37 chuck Exp $
 *
 * Copyright 2000-2004 Charles J. Hagenbuch <chuck at horde.org>
 *
 * See the enclosed file COPYING for license information (GPL). If you did not
 * receive this file, see http://www.fsf.org/copyleft/gpl.html.
 */

@define('TURBA_BASE', dirname(__FILE__));
require_once TURBA_BASE . '/lib/base.php';
require_once TURBA_BASE . '/lib/Source.php';
require TURBA_BASE . '/config/attributes.php';

/* Verify if the search mode variable is passed in form or is registered in
   the session. Always use basic search by default */
if (Util::getFormData('search_mode')) {
    $_SESSION['turba_search_mode'] = Util::getFormData('search_mode');
}
if (!isset($_SESSION['turba_search_mode'])) {
    $_SESSION['turba_search_mode'] = 'basic';
}

/* Make sure the search session variable is registered in the session,
 * and obtain a global-scope reference to it. */
if (!$conf['search']['cache'] || !isset($_SESSION['turba_search_results'])) {
    $_SESSION['turba_search_results'] = null;
} else {
    if (Util::getFormData('clear')) {
        $_SESSION['turba_search_results'] = null;
    } elseif (!empty($_SESSION['turba_search_results'])) {
        require_once TURBA_BASE . '/lib/List.php';
        require_once TURBA_BASE . '/lib/Object.php';
        $_SESSION['turba_search_results'] = Turba_List::unserialize($_SESSION['turba_search_results']);
    }
}

/* Run search if there is one. */
$source = Util::getFormData('source');
if (!isset($source) && isset($cfgSources) && is_array($cfgSources) && count($cfgSources) > 0) {
    $source = $prefs->getValue('default_dir');
}
if (!isset($cfgSources[$source])) {
    reset($cfgSources);
    $source = key($cfgSources);
}

$criteria = Util::getFormData('criteria');
$val = Util::getFormData('val');
$driver = &Turba_Source::singleton($source, $cfgSources[$source]);
if (is_a($driver, 'PEAR_Error')) {
    $notification->push(_("Failed to connect to the specified directory."), 'horde.error');
    $map = array();
} else {
    $map = $driver->getCriteria();

    if ($_SESSION['turba_search_mode'] == 'advanced') {
        $criteria = array();
        foreach ($map as $key => $value) {
            if ($key != '__key') {
                $val = Util::getFormData($key);
                if (!empty($val)) {
                    $criteria[$key] = $val;
                }
            }
        }
    }

    if (isset($criteria) && isset($val)) {
        if (($_SESSION['turba_search_mode'] == 'basic' && is_object($results = $driver->search(array($criteria => $val)))) ||
            ($_SESSION['turba_search_mode'] == 'advanced' && is_object($results = $driver->search($criteria)))) {

            if (!is_object($_SESSION['turba_search_results'])) {
                $_SESSION['turba_search_results'] = &new Turba_List();
            }
            $combinedResults = &new Turba_List();
            $combinedResults->merge($_SESSION['turba_search_results'], false);
            $combinedResults->merge($results);
            $_SESSION['turba_search_results'] = $combinedResults->serialize();

            $url = Util::addParameter('browse.php', 'key', '**search');
            $url = Util::addParameter($url, 'source', $source);

            header('Location: ' . Horde::applicationUrl($url, true));
        } else {
            $notification->push(sprintf(_("Failed to search the directory: %s"), ''), 'horde.error');
        }
    }
}

if ($_SESSION['turba_search_mode'] == 'basic') {
    $title = _("Basic Search");
    $notification->push('document.directory_search.val.focus();', 'javascript');
} else {
    $title = _("Advanced Search");
    $notification->push('document.directory_search.name.focus();', 'javascript');
}

require TURBA_TEMPLATES . '/common-header.inc';
Turba::menu();
require TURBA_TEMPLATES . '/browse/search.inc';
if ($_SESSION['turba_search_mode'] == 'advanced') {
    require TURBA_TEMPLATES . '/browse/search_criteria.inc';
}
require $registry->getParam('templates', 'horde') . '/common-footer.inc';

if (is_object($_SESSION['turba_search_results'])) {
    $_SESSION['turba_search_results'] = $_SESSION['turba_search_results']->serialize();
}

--- NEW FILE: test.php ---
<?php
/**
 * $Horde: turba/test.php,v 1.8 2004/02/25 21:21:37 chuck Exp $
 *
 * Copyright 2000-2004 Brent J. Nordquist <bjn at horde.org>
 *
 * See the enclosed file COPYING for license information (GPL). If you did not
 * receive this file, see http://www.fsf.org/copyleft/gpl.html.
 */

/* Include Horde's core.php file. */
include_once '../lib/core.php';

/* We should have loaded the String class, from the Horde_Util
 * package, in core.php. If String:: isn't defined, then we're not
 * finding some critical libraries. */
if (!class_exists('String')) {
    echo '<br /><span style="color: red; font-size: 18px; font-weight: bold;">The Horde_Util package was not found. If PHP\'s error_reporting setting is high enough, there should be error messages printed above that may help you in debugging the problem. If you are simply missing these files, then you need to get the <a href="http://cvs.horde.org/cvs.php/framework">framework</a> module from <a href="http://horde.org/source/">Horde CVS</a>, and install the packages in it with the install-packages.php script.</span>';
    exit;
}

/* Initialize the Horde_Test:: class. */
if (!(@is_readable('../lib/Test.php'))) {
    echo 'ERROR: You must install Horde before running this script.';
    exit;
}
require_once '../lib/Test.php';
$horde_test = &new Horde_Test;

/* Turba version. */
$module = 'Turba';
require_once './lib/version.php';
$module_version = TURBA_VERSION;

require TEST_TEMPLATES . 'header.inc';
require TEST_TEMPLATES . 'version.inc';

/* Display PHP Version information. */
$php_info = $horde_test->getPhpVersionInformation();
require TEST_TEMPLATES . 'php_version.inc';

/* PHP modules. */
$module_list = array(
    'mysql' => 'MySQL Support',
    'pgsql' => 'PostgreSQL Support',
    'mssql' => 'Microsoft SQL Support',
    'oci8' => 'Oracle Support',
    'odbc' => 'Unified ODBC Support',
    'ldap' => 'LDAP Support'
);

/* Get the status output now. */
$module_output = $horde_test->phpModuleCheck($module_list);

?>

<h1>PHP Module Capabilities</h1>
<ul>
    <?php echo $module_output ?>
</ul>

<h1>PHP LDAP Support Test</h1>
<?php

$server = isset($_POST['server']) ? $_POST['server'] : ''; // 'server.example.com';
$port = isset($_POST['port']) ? $_POST['port'] : ''; // '389';
$basedn = isset($_POST['basedn']) ? $_POST['basedn'] : ''; // 'dc=example,dc=com';
$user = isset($_POST['user']) ? $_POST['user'] : '';     // 'user';
$passwd = isset($_POST['passwd']) ? $_POST['passwd'] : ''; // 'password';
$filter = isset($_POST['filter']) ? $_POST['filter'] : ''; // 'cn=Babs Jensen';

if (!empty($server) && !empty($basedn) && !empty($filter)) {
    if (empty($port)) {
        $port = '389';
    }
    echo 'server="', $server, '" basedn="', $basedn, '" filter="', $filter, '"<br />';
    if ($user) {
        echo 'bind as user="', $user, '"<br />';
    } else {
        echo 'bind anonymously<br />';
    }
    $ldap = ldap_connect($server, $port);
    if ($ldap) {
        if (!empty($user) && !ldap_bind($ldap, $user, $passwd)) {
            echo "<p>unable to bind as $user to LDAP server</p>\n";
            ldap_close($ldap);
            $ldap = '';
        } elseif (empty($user) && !ldap_bind($ldap)) {
            echo "<p>unable to bind anonymously to LDAP server</p>\n";
            ldap_close($ldap);
            $ldap = '';
        }
        if ($ldap) {
            $result = ldap_search($ldap, $basedn, $filter);
            if ($result) {
                echo '<p>search returned ' . ldap_count_entries($ldap, $result) . " entries</p>\n";
                $info = ldap_get_entries($ldap, $result);
                for ($i = 0; $i < $info['count']; $i++) {
                    echo '<p>dn is: ' . $info[$i]['dn'] . '<br />';
                    echo 'first cn entry is: ' . $info[$i]['cn'][0] . '<br />';
                    echo 'first mail entry is: ' . $info[$i]['mail'][0] . '</p>';
                    if ($i >= 10) {
                        echo '<p>(only first 10 entries displayed)</p>';
                        break;
                    }
                }
            } else {
                echo '<p>unable to search LDAP server</p>';
            }
        }
    } else {
        echo '<p>unable to connect to LDAP server</p>';
    }
} else {
    ?>
<form name="form1" method="post" action="test.php">
<table>
<tr><td align="right">Server</td><td><input type="text" name="server" /></td></tr>
<tr><td align="right">Port</td><td><input type="text" name="port" /></td><td>(defaults to "389")</td></tr>
<tr><td align="right">Base DN</td><td><input type="text" name="basedn" /></td><td>(e.g. "dc=example,dc=com")</td></tr>
<tr><td align="right">User</td><td><input type="text" name="user" /></td><td>(leave blank for anonymous)</td></tr>
<tr><td align="right">Password</td><td><input type="password" name="passwd" /></td></tr>
<tr><td align="right">Filter</td><td><input type="text" name="filter" /></td><td>(e.g. "cn=Babs Jensen")</td></tr>
<tr><td></td><td><input type="submit" name="f_submit" value="Submit" /><input type="reset" name="f_reset" value="Reset" /></td></tr>
</table>
</form>
<?php } ?>

</td></tr>
</table>

<?php
require TEST_TEMPLATES . 'footer.inc';

--- NEW FILE: vcard.php ---
<?php
/**
 * $Horde: turba/vcard.php,v 1.7 2004/05/10 13:41:05 jan Exp $
 *
 * Copyright 2000-2004 Charles J. Hagenbuch <chuck at horde.org>
 *
 * See the enclosed file COPYING for license information (GPL). If you did not
 * receive this file, see http://www.fsf.org/copyleft/gpl.html.
 */

define('TURBA_BASE', dirname(__FILE__));
require_once TURBA_BASE . '/lib/base.php';
require_once 'Horde/Form.php';
require_once 'Horde/Data.php';
require_once TURBA_BASE . '/lib/Renderer.php';
require_once TURBA_BASE . '/lib/Source.php';
require_once 'Horde/Variables.php';

$vars = &Variables::getDefaultVariables();

$source = $vars->get('source');
if (!isset($cfgSources[$source])) {
    $notification->push(_("The contact you requested does not exist."), 'horde.error');
    header('Location: ' . Horde::applicationUrl($prefs->getValue('initial_page'), true));
    exit;
}

$driver = &Turba_Source::singleton($source, $cfgSources[$source]);

/* Set the contact from the key requested. */
$key = $vars->get('key');
$object = $driver->getObject($key);
if (is_a($object, 'PEAR_Error')) {
    $notification->push($object->getMessage(), 'horde.error');
    header('Location: ' . Horde::applicationUrl($prefs->getValue('initial_page'), true));
    exit;
}

/* Check permissions on this contact. */
if (!Turba::checkPermissions($object, 'object', PERMS_READ)) {
    $notification->push(_("You do not have permission to view this object."), 'horde.error');
    header('Location: ' . Horde::applicationUrl($prefs->getValue('initial_page'), true));
    exit;
}

$vars = array();
/* Get the values through the AbstractObject class. */
foreach ($object->source->getCriteria() as $info_key => $info_val) {
    $vars[$info_key] = $object->getValue($info_key);
}

/* Get the contact's history. */
$history = &Horde_History::singleton();
$log = $history->getHistory($driver->getGUID($key));
foreach ($log->getData() as $entry) {
    switch ($entry['action']) {
    case 'add':
        $vars['__created'] = strftime($prefs->getValue('date_format'), $entry['ts']) . ' ' . date($prefs->getValue('twentyFour') ? 'G:i' : 'g:i a', $entry['ts']);
        break;

    case 'modify':
        $vars['__modified'] = strftime($prefs->getValue('date_format'), $entry['ts']) . ' ' . date($prefs->getValue('twentyFour') ? 'G:i' : 'g:i a', $entry['ts']);
        break;
    }
}

$vcard = &Horde_Data::singleton('vcard');
$vcard->exportFile(_("contact.vcf"), $vcard->fromHash($vars), NLS::getCharset());





More information about the commits mailing list