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

  function ShowFormEditFavorites() {

    // vars global configuration
    global $theme_path;

    // vars url & form
    global $id;

    // vars messages
    global $msg;

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

    $links_obj = new clsLink;
    $links_obj->favorite_table_name = "idx_favorites";
    $links_obj->template_file       = $theme_path . "cp/favorite_edit_form.html";
    $edit_result                    = $links_obj->EditFavorite("display_form", $_COOKIE['COOKIE_USERNAME'], $id);

    // if user is not the owner
    if ($edit_result == 1)
      DisplayTemplate($theme_path . "cp/not_allowed.html");
  }


  /*===================================================
    ProcessFormEditFavorites()
  ===================================================*/
  
  function ProcessFormEditFavorites() {

    // 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["20071"];

    if (empty($error_msg)) {
      $links_obj = new clsLink;
        $links_obj->favorite_table_name = "idx_favorites";
      $links_obj->template_file       = $theme_path . "cp/favorite_edit_ok.html";
      $links_obj->EditFavorite("process_form", $_COOKIE['COOKIE_USERNAME'], $id);

      if ($edit_result == 1)
        DisplayTemplate($theme_path . "cp/not_allowed.html");
    }
    else {
      ShowFormEditFavorites();
    }
  }


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

  include "../application.php";

  RunPreFilter(__FILE__);

  if (empty($pflag)) {
    ShowFormEditFavorites();
  }
  elseif ($pflag == 'edit') {
    ProcessFormEditFavorites();
  }

  RunPostFilter(__FILE__);

?>