<?php
if(!defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
/**
 *
 * @package  MediaLibrary
 * @copyright 2021 Andrey Kvasnevskiy-OrdaSoft(akbet@mail.ru); Rob de Cleen(rob@decleen.com);
 * Homepage: https://ordasoft.com
 * @version: 4.6 Free
 * @license GNU General Public license version 2 or later; see LICENSE.txt
 *
 */


if( stristr( $_SERVER['PHP_SELF'], 'administrator')) {
    @define( '_VM_IS_BACKEND', '1' );
}
defined('_VM_TOOLBAR_LOADED' ) or define('_VM_TOOLBAR_LOADED', 1 );

include_once( JPATH_SITE."/components/com_medialibrary/compat.joomla1.5.php" );


$path = JPATH_SITE."/administrator/components/com_medialibrary/";

// ensure this file is being included by a parent file

require_once( $path . 'toolbar.medialibrary.php' );
require_once( $path . 'toolbar.medialibrary.html.php' );

$database = JFactory::getDBO();
$section = mosGetParam( $_REQUEST, 'section', 'courses' );

// load language
require_once $mosConfig_absolute_path . "/administrator/components/com_medialibrary/language.php";


if (isset($_REQUEST['task']))
{
  $task = mosGetParam($_REQUEST, 'task', '');
} else { $task = '';}


//print_r($task);
if (isset($section) && $section=='categories') {

switch ($task) {

  case "add": // use 'add' instead 'new' in J 1.6
    menucat::NEW_CATEGORY();
    break;
  case "edit":
    menucat::EDIT_CATEGORY();
    break;
  default:
    menucat::SHOW_CATEGORIES();
    addSubmenuMEdiaLibrary("Categories");
    break;
  }
}elseif ($section == 'language_manager')
{
    switch ($task) {

        case "copy":
            menulanguagemanager::EDIT_LANGUAGEMANAGER();
            addSubmenuMediaLibrary("Language Manager");
            break;
        case "edit":
            menulanguagemanager::EDIT_LANGUAGEMANAGER();
            addSubmenuMediaLibrary("Language Manager");
            break;
        default:
            menulanguagemanager::MENU_LANGUAGEMANAGER();
            addSubmenuMediaLibrary("Language Manager");
            break;
    }
}
 else {


  switch ($task) {

    case "add": // use 'add' instead 'new' in J 1.6
      menumedialibrary::MENU_SAVE_BACKEND();
      break;

    case "edit":
    case "clone_media":
      menumedialibrary::MENU_EDIT();
      break;

    case "refetchInfos":
      menumedialibrary::MENU_REFETCH_INFOS();
      break;

    case "user_lend_history":
      // menumedialibrary::MENU_USER_LEND_HISTORY();
      //menumedialibrary::MENU_LEND();
      addSubmenuMediaLibrary("User Lend History");
      break;

    case "show_import_export":
      menumedialibrary::MENU_IMPORT_EXPORT();
      addSubmenuMediaLibrary("Import/Export");
      break;

    case "lend":
      menumedialibrary::MENU_LEND();
      break;

    case "lend_return":
      menumedialibrary::MENU_LEND_RETURN();
      addSubmenuMediaLibrary("Lend Requests");
      break;

    case "lend_requests":
      menumedialibrary::MENU_LENDREQUESTS();
      addSubmenuMediaLibrary("Lend Requests");
      break;

    case "import":
      menumedialibrary::MENU_CANCEL();
      break;

    case "export":
      menumedialibrary::MENU_CANCEL();
      break;

    case "config":
    case "config_save":
      menumedialibrary::MENU_CONFIG();
      addSubmenuMediaLibrary("Settings");
      break;

    case "about":
      menumedialibrary::MENU_ABOUT();
      addSubmenuMediaLibrary("About");
      break;

    case "delete_review":
      menumedialibrary::MENU_DELETE_REVIEW();
      break;

    case "edit_review":
      menumedialibrary::MENU_EDIT_REVIEW();
      break;

    case "update_review":
      menumedialibrary::MENU_EDIT();
      break;

    case "cancel_review_edit":
      menumedialibrary::MENU_EDIT();
      break;

  //**************   begin for manage reviews   *********************
    case "manage_review":
      menumedialibrary::MENU_MANAGE_REVIEW();
      addSubmenuMediaLibrary("Reviews");
      break;

    case "delete_manage_review":
      menumedialibrary::MENU_MANAGE_REVIEW_DELETE();
      addSubmenuMediaLibrary("Reviews");
      break;

    case "edit_manage_review":
      menumedialibrary::MENU_MANAGE_REVIEW_EDIT();
      break;

    case "update_edit_manage_review":
      menumedialibrary::MENU_MANAGE_REVIEW_EDIT_EDIT();
      addSubmenuMediaLibrary("Reviews");
      break;

    case "cancel_edit_manage_review":
      menumedialibrary::MENU_MANAGE_REVIEW_EDIT_EDIT();
      addSubmenuMediaLibrary("Reviews");
      break;

    case "sorting_manage_review_numer":
      menumedialibrary::MENU_MANAGE_REVIEW();
      addSubmenuMediaLibrary("Reviews");
      break;

    case "sorting_manage_review_title_catigory":
      menumedialibrary::MENU_MANAGE_REVIEW();
      addSubmenuMediaLibrary("Reviews");
      break;

    case "sorting_manage_review_isbn":
      menumedialibrary::MENU_MANAGE_REVIEW();
      addSubmenuMediaLibrary("Reviews");
      break;

    case "sorting_manage_review_media_title":
      menumedialibrary::MENU_MANAGE_REVIEW();
      addSubmenuMediaLibrary("Reviews");
      break;

    case "sorting_manage_review_media_type":
      menumedialibrary::MENU_MANAGE_REVIEW();
      addSubmenuMediaLibrary("Reviews");
      break;

    case "sorting_manage_review_title_book":
      menumedialibrary::MENU_MANAGE_REVIEW();
      addSubmenuMediaLibrary("Reviews");
      break;

    case "sorting_manage_review_title_category":
      menumedialibrary::MENU_MANAGE_REVIEW();
      addSubmenuMediaLibrary("Reviews");
      break;

    case "sorting_manage_review_title_review":
      menumedialibrary::MENU_MANAGE_REVIEW();
      addSubmenuMediaLibrary("Reviews");
      break;

    case "sorting_manage_review_published":
      menumedialibrary::MENU_MANAGE_REVIEW();
      addSubmenuMediaLibrary("Reviews");
      break;

    case "sorting_manage_review_user_name":
      menumedialibrary::MENU_MANAGE_REVIEW();
      addSubmenuMediaLibrary("Reviews");
      break;

    case "sorting_manage_review_date":
      menumedialibrary::MENU_MANAGE_REVIEW();
      addSubmenuMediaLibrary("Reviews");
      break;

    case "sorting_manage_review_rating":
      menumedialibrary::MENU_MANAGE_REVIEW();
      addSubmenuMediaLibrary("Reviews");
      break;
  //**************   end for manage reviews   ***********************

 //******************** begin userlendhistory ****************
    case "sorting_userlend_media_type_id":
      addSubmenuMediaLibrary("User Lend History");
      break;
    case "sorting_userlend_media_type":
      addSubmenuMediaLibrary("User Lend History");
      break;
    case "sorting_userlend_media_type":
      addSubmenuMediaLibrary("User Lend History");
      break;
    case "sorting_userlend_media_title":
      addSubmenuMediaLibrary("User Lend History");
      break;
    case "sorting_userlend_lendfrom":
      addSubmenuMediaLibrary("User Lend History");
      break;
    case "sorting_userlend_lentuntil":
      addSubmenuMediaLibrary("User Lend History");
      break;
	case "sorting_userlend_returnmedia":
      addSubmenuMediaLibrary("User Lend History");
      break;
    case "sorting_userlend_email":
      addSubmenuMediaLibrary("User Lend History");
      break;

 //******************** end userlendhistory ****************

    case "manage_author":
      menumedialibrary::MENU_MANAGE_AUTHOR();
      addSubmenuMediaLibrary("Add Author");
      break;
    case "add_author":
      menumedialibrary::MENU_ADD_AUTHOR();
      break;
    case "edit_author":
    case "clone_author":
      menumedialibrary::MENU_ADD_AUTHOR();
      break;
    default:
      menumedialibrary::MENU_DEFAULT();
      addSubmenuMediaLibrary("Media");
      break;
  }

} //else


