<?php

/**
 *
 * INDEXU
 * Copyright(C), Nicecoder, 2000-2006, All Rights Reserved.
 *
 * INDEXU(tm) is protected by Indonesia and International copyright laws.
 * Unauthorized use or distribution of INDEXU(tm) is strictly prohibited,
 * violators will be prosecuted. To obtain a license for using INDEXU(tm),
 * please register at Nicecoder home page at http://www.nicecoder.com
 *
 * Author:
 *    Dody Rachmat Wicaksono (dody@nicecoder.com)
 *    M. Zuber (zubby@nicecoder.com)
 *
 */

  /*===================================================
    ShowFormSearchUser()
  ===================================================*/

  function ShowFormSearchUser() {

    // vars global configuration
    global $admin_template_path;

    // vars url & form

    // vars messages

    // vars template

    DisplayTemplate($admin_template_path . "user_search_form.html");
  }


  /*===================================================
    ProcessFormSearchUser()
  ===================================================*/

  function ProcessFormSearchUser() {

    // vars global configuration
    global $admin_template_path;

    // vars url & form
    global $username, $password, $email, $name, $homepage, $icq, $yahoo,
      $aol, $biography, $interest, $location, $occupation, $pg_which;

    // vars messages
    global $msg;

    // vars template
    global $user, $pagination, $param, $num_rows, $back;

    $users_obj = new clsUsers;
    $users_obj->table_name = "idx_users";
    $users_obj->template_file = $admin_template_path . "user_search_result_rows.html";
    $users_obj->paging = true;
    
    $fields = $users_obj->GetFields();

    // ----- querying -----

    $query = "select * from idx_users where 0=0 ";
    $i = 0;
    $count_fields = @count($fields);
    while ($i < $count_fields) {
      $field = $fields[$i];

      if(!empty($$field))
        $query .= "and $field like '%".$$field."%' ";

      $i++;
    }
    $query .= " and status=1 order by username ";

    $users_obj->query = $query;
    
    $par = "&pflag=search&username=$username&email=$email&name=$name&homepage=$homepage&icq=$icq&yahoo=$yahoo".
     "&aol=$aol&biography=$biography&interest=$interest&location=$location&occupation=$occupation";

    $users_obj->more_param = $par;

    $user = $users_obj->DisplayUsers();
    $pagination = $users_obj->pagination;
    $num_rows = $users_obj->num_rows;
    
    $people_icon = $admin_template_path . "/images/tree_leaf.jpg";
    $people_icon = $space."<img src=people_icon border=0> ";
    
    $back = "user_search.php?$par";
    
    DisplayTemplate($admin_template_path . "user_search_result.html",
      "\$user,\$pagination,\$param,\$num_rows,\$back");
  }


  /*===================================================
    main
  ===================================================*/

  include "../application.php";

  RunPreFilter(__FILE__);

  DisplayTemplate($admin_template_path . "header.html");
  if (empty($pflag)) {
    ShowFormSearchUser();
  }
  elseif ($pflag == 'search') {
    ProcessFormSearchUser();
  }
  DisplayTemplate($admin_template_path . "footer.html");

  RunPostFilter(__FILE__);

?>