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

  function DeleteLink() {

    // vars global configuration
    global $theme_path;

    // vars url & form
    global $num_rows;

    // vars messages
    global $msg;

    // vars template
    global $message;

    $tpl = new Template();

    $links_obj = new clsLink;
    $links_obj->table_name = "idx_link";

    $i                     = 1;

    while ($i <= $num_rows) {
      $var = "chkbox_$i";
      $id  = $GLOBALS["$var"];

      if (!empty($id)) {
        $title         = $links_obj->GetLinkTitle($id);
        $delete_result = $links_obj->Delete($id);

        if ($delete_result == 0)
          $message .= $msg["20141"];

        $tpl->assign('title', $title);

        $message = $tpl->fetch('var:' . $message);
      }

      $i++;
    }

    if (empty($message))
      $message = $msg["20142"];

    DisplayTemplate($theme_path . "cp/editor_link_delete.html", "\$message");
  }


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

  include "../application.php";

  AddFilter('validate_editor');
  RunPreFilter(__FILE__);
  
  DeleteLink();

  RunPostFilter(__FILE__);

?>