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

  /*===================================================
    ShowUserCP()
  ===================================================*/

  function ShowUserCP() {

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

    // vars messages
    global $msg;

    // vars template
    global $favorite, $editor_menu, $category, $subscribe_list;

    global $dbConn;


    // get list of favorites
    $links_obj = new clsLink;
    $links_obj->table_name    = "idx_link";
    $links_obj->favorite_table_name = "idx_favorites";
    $links_obj->editor_table_name = "idx_editor";
    $links_obj->max_rows          = 50;
    $links_obj->date_format       = $msg["20001"];
    $links_obj->query             = "select * from idx_favorites where username = '$_COOKIE[COOKIE_USERNAME]'";
    $links_obj->template_file     = $theme_path . "cp/fav_rows.html";
    $favorite                     = $links_obj->DisplayFavorites();

    $category_obj = new clsCategory;
    $category_obj->table_name      = "idx_category";
    $category_obj->link_table_name = "idx_link";
    $category_obj->separator       = $category_separator;

    // get editor menu

    $users_obj = new clsUsers;
    $users_obj->table_name = "idx_users";
    if ($users_obj->GetUserAuthentication(1) == 0) {
      // get category for this editor
      $categories = $links_obj->GetEditorCategory($_COOKIE['COOKIE_USERNAME']);
      while (list(, $v) = @each($categories)) {
        $category .= $category_obj->GetCategoryPath($v) . "<br>";
      }
      // display editor's menu
      $editor_menu = EvalTemplate($theme_path . "cp/editor_menu.html", "\$category");
    }

    // get user subscribed category
    $query  = "select category_id from idx_notification where username = '$_COOKIE[COOKIE_USERNAME]'";
    $result = $dbConn->Execute($query);
    $subscribe_list = array();
    while ($row = $result->FetchRow()) {
      $row['path_with_url'] = $category_obj->GetCategoryPath($row['category_id']);
      $subscribe_list[] = $row;
    }

    DisplayTemplate($theme_path . "cp/index.html", "\$favorite,\$subscribe_list,\$editor_menu");
  }


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

  include "../application.php";

  RunPreFilter(__FILE__);

  ShowUserCP();

  RunPostFilter(__FILE__);

?>