<?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)
 *
 */

  /*===================================================
    ShowFormDeleteEditor()
  ===================================================*/

  function ShowFormDeleteEditor() {

    // vars global configuration
    global $category_separator, $admin_template_path;

    // vars url & form
    global $username, $cat;
    
    // vars messages
    global $msg;

    // vars template
    global $category;
    
    $tpl = new Template();
    
    // show user detail
    $users_obj = new clsUsers;
    $users_obj->table_name = "idx_users";
    $users_obj->max_rows = 1;
    $users_obj->template_file = $admin_template_path . "editor_delete_form.html";
    $users_obj->query = "select * from idx_users where username = '$username'";
    $detail = $users_obj->DisplayUsers();
    

    // category's path
    $category_obj = new clsCategory;
    $category_obj->table_name = "idx_category";
    $category_obj->separator = $category_separator;
    $category = $category_obj->GetCategoryPath($cat);
    
    $tpl->assign('category', $category);
    $tpl->assign('cat', $cat);
    $detail = $tpl->fetch('var:' . $detail);
    
    print $detail;
  }


  /*===================================================
    ProcessFormDeleteEditor()
  ===================================================*/

  function ProcessFormDeleteEditor() {

    // vars global configuration
    global $category_separator, $admin_template_path;

    // vars url & form
    global $cat, $username;

    // vars messages
    global $msg;

    // vars template
    global $message, $back;

    $links_obj = new clsLink;
    $links_obj->table_name = "idx_link";
    $links_obj->category_table_name = "idx_category";
    $links_obj->editor_table_name = "idx_editor";
    $links_obj->user_table_name = "idx_users";
    
    // category's path
    $category_obj = new clsCategory;
    $category_obj->table_name = "idx_category";
    $category_obj->separator = $category_separator;
    $category = $category_obj->GetCategoryPath($cat);

    $links_obj->DeleteEditor($username,$cat);

    $message = $msg["20241"];
    $tpl = new Template();
    $tpl->assign('username', $username);
    $tpl->assign('category', $category);
    $message = $tpl->fetch('var:' . $message);

    $back = "<a href=cat_view.php>Back</a>";

    DisplayTemplate($admin_template_path . "message.html", "\$message,\$back");
  }


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

  include "../application.php";
  
  RunPreFilter(__FILE__);

  DisplayTemplate($admin_template_path . "header.html");
  if (empty($pflag)) {
    ShowFormDeleteEditor();
  }
  elseif ($pflag == 'delete') {
    ProcessFormDeleteEditor();
  }
  DisplayTemplate($admin_template_path . "footer.html");
 
  RunPostFilter(__FILE__);

?>