Location: PHPKode > projects > LDAPted > ldapted/includes/addons/SearchList.php
<?php
/***************************************************************************
 *
 *                                 SearchList.php
 *                              -------------------
 *
 *   begin                : Friday, Nov 17, 2002
 *   copyright            : (C) 2002 The Kabramps Team
 *   email                : hide@address.com,
 *                          hide@address.com
 *
 *
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 *   See the GNU General Public License for more details.
 *   (http://www.gnu.org/licenses/gpl.html)
 *
 ***************************************************************************/

class SearchList extends Addon {

  function SearchList() {
  }

  function get_view() {
    global $HTTP_POST_VARS;
    global $ldap;
    global $formular;
    global $attribute;
    global $addonoptions;

    $search = $HTTP_POST_VARS['search'];
    $list = $HTTP_POST_VARS['list'];
    $tmpl = new Smarty;

    $searchdn = $addonoptions['searchdn'];
    $return = $addonoptions['searchattribute'];
    if ( $search ) {
      $filter = $return."=".$search;
      $answer = $ldap->search($searchdn, array($return), $filter,true);
      for ( $i=0; $i<count($answer); $i++ ) {
	$entry = $answer[$i][$return][0];
	if (  count($list) > 0 ) {
	  if ( ! in_array($entry,$list) ) {
	    $result[] = $entry;
	  }
	} else $result[] = $entry;
      }
    }

    $tmpl->assign(array("SEARCH"      => $search,
			"ENTRY"       => $list,
			"RESULT"      => $result,
			"STATUS"      => $HTTP_POST_VARS['status'],
			"SUBMIT"      => gettext("ok"),
			"CLOSE"       => gettext("cancel"),
			"ATTRIBUTE"   => $attribute,
			"ATTRIBUTELABEL" => $attribute
			));
    
    return $tmpl->fetch("addons/searchlist.tpl");
  }
  
  function get_jsfile() {
    global $options;
    return array( $options['templates']."addons/list.js",
		  $options['templates']."addons/values.js",
		  $options['templates']."addons/searchlist.js"
		  );
  }
  
  function onload() {
    return "check_values('list[]');";
  }
}
Return current item: LDAPted