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

  function ShowFormCreateFavorite() {

    // vars global configuration
    global $theme_path;

    // vars url & form
    global $id;

    // vars messages
    global $msg;

    // vars template
    global $error_msg, $title, $description;

    $title       = $_POST["title"];
    $title       = stripslashes($title);
    $description = stripslashes($description);

    DisplayTemplate($theme_path . "cp/favorite_create_form.html", "\$error_msg,\$title,\$description");
  }


  /*===================================================
    ProcessFormCreateFavorite()
  ===================================================*/
  
  function ProcessFormCreateFavorite() {

    // vars global configuration
    global $theme_path;

    // vars url & form
    global $id, $title, $description;

    // vars messages
    global $msg;

    // vars template
    global $error_msg;


    // verify input

    $title = $_POST["title"];

    if (empty($title))
      $error_msg = $msg["20081"];

    if (empty($error_msg)) {
      $links_obj = new clsLink;
        $links_obj->favorite_table_name = "idx_favorites";
      $links_obj->CreateFavorite($_COOKIE['COOKIE_USERNAME'], $title, $description);

      DisplayTemplate($theme_path . "cp/favorite_create_ok.html");
    }
    else {
      ShowFormCreateFavorite();
    }
  }


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

  include "../application.php";

  RunPreFilter(__FILE__);

  if (empty($pflag)) {
    ShowFormCreateFavorite();
  }
  elseif ($pflag == 'create') {
    ProcessFormCreateFavorite();
  }

  RunPostFilter(__FILE__);

?>