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

  function ShowFormDeleteFavorite() {

    // vars global configuration
    global $dbConn, $theme_path;

    // vars url & form
    global $id;

    // vars messages
    global $msg;

    // vars template
    global $title;

    $query  = "select title from idx_favorites where favorite_id = '$id'";
    $result = $dbConn->Execute($query);
    $title  = $result->Fields("title");

    DisplayTemplate($theme_path . "cp/favorite_delete_confirm.html", "\$title,\$id");
  }


  /*===================================================
    ProcessFormDeleteFavorite()
  ===================================================*/
  
  function ProcessFormDeleteFavorite() {

    // vars global configuration
    global $theme_path;

    // vars url & form
    global $id;

    // vars messages
    global $msg;

    // vars template
    global $error_msg;


    // verify input

    $links_obj = new clsLink;
    $links_obj->favorite_table_name        = "idx_favorites";
    $links_obj->favorite_detail_table_name = "idx_favorites_detail";
    $delete_result                         = $links_obj->DeleteFavorite($_COOKIE['COOKIE_USERNAME'], $id);

    if ($delete_result == 0)
      DisplayTemplate($theme_path . "cp/favorite_delete_ok.html");
    elseif ($delete_result == 1)
      DisplayTemplate($theme_path . "cp/not_allowed.html");
  }


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

  include "../application.php";

  RunPreFilter(__FILE__);

  if (empty($pflag)) {
    ShowFormDeleteFavorite();
  }
  elseif ($pflag == 'delete') {
    ProcessFormDeleteFavorite();
  }

  RunPostFilter(__FILE__);

?>