<?php
/**
*
* copied from /bootstrap3/templates/myresearch/menu.phtml
* changed for fid specific menu
* refs #15480 add password change to fid profile
*
* @author   Robert Lange <lange@@ub.uni-leipzig.de>
* @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link     https://vufind.org Main Page
*/
?>
<!-- fid-adlr myresearch - menu -->
<?php
  $user = $this->auth()->isLoggedIn();
?>
<?php /* Offcanvas closing button missing in BS3! CK*/ ?>
<button class="close-offcanvas btn btn-link right" data-toggle="offcanvas"><i class="icon icon-close icon-2x"></i></button>
<div class="clearfix"></div>

<?php if (!empty($user)): ?>

  <?php if ($this->userlist()->getMode() !== 'disabled'): ?>
    <h4><?=$this->transEsc('Your Lists')?></h4>

    <div class="myresearch-menu">
      <a href="<?=$this->url('myresearch-favorites')?>"<?=$this->active == 'favorites' ? ' class="active"' : ''?>>
        <i class="icon icon-star" aria-hidden="true"></i> <?=$this->transEsc('Your Favorites')?>
      </a>
      <?php $lists = $user->getLists() ?>
      <?php foreach ($lists as $list): ?>
        <a href="<?=$this->url('userList', ['id' => $list['id']])?>"<?=$this->active == 'list' . $list['id'] ? ' class="active"' : ''?>>
          <span class="list-link"><?=$this->escapeHtml($list['title'])?></span>
          <span class="badge"><?=$list->cnt != 0 ? $list->cnt : '' ?></span>
        </a>
      <?php endforeach; ?>

      <a href="<?=$this->url('editList', ['id' => 'NEW'])?>">
        <i class="icon icon-plus" aria-hidden="true"></i> <?=$this->transEsc('Create a List') ?>
      </a>

      <? /* link to listing of debis databases etc. */ ?>
      <?php if ($this->permission()->allowDisplay('access.Licenses') || $this->permission()->allowDisplay('access.DBIS')) : ?>
        <a href="<?=$this->url('myresearch/databases')?>" <?=$this->active == 'databases' ? ' class="active"' : ''?> >
          <i class="icon icon-window" aria-hidden="true"></i> <?=$this->transEsc('database_access')?>
        </a>
      <?php endif; ?>

      <?php /* refs #16033 order list page link */ ?>
        <a data-lightbox href="<?=$this->url('fid/user/orders')?>">
          <span class="no-padding">
            <i class="icon icon-package" aria-hidden="true"></i>
          </span>
          <?=$this->transEsc('Your Orders')?>
        </a>

      <?php if ($this->accountCapabilities()->getSavedSearchSetting() === 'enabled'): ?>
        <a href="<?=$this->url('search-history')?>?require_login"<?=$this->active == 'history' ? ' class="active"' : ''?>>
          <i class="icon icon-download" aria-hidden="true"></i> <?=$this->transEsc('history_saved_searches')?>
        </a>
      <?php endif; ?>

      <?php /* refs #16033 / #16510 new print publications page link */ ?>
      <?php if (!empty($this->config()->get('config')->RawQueries['new_releases'])): ?>
        <a href="<?= $this->url('search-results') ?><?= $this->config()->get('config')->RawQueries['new_releases']?>">
          <span class="no-padding">
            <i class="icon icon-book" aria-hidden="true"></i>
          </span>
          <?=$this->transEsc('new_print_publications')?>
        </a>
      <?php endif; ?>
    </div>
    <br />
  <?php endif ?>

  <h4><?=$this->transEsc('Your Account')?></h4>
  <div class="myresearch-menu account-menu">
    <?php if ('ils-none' !== $this->ils()->getOfflineMode()): ?>
      <a href="<?= $this->url('myresearch-profile') ?>" <?= $this->active == 'profile' ? ' class="active"' : '' ?>>
        <i class="icon icon-user" aria-hidden="true"></i>
        <?= $this->transEsc('Profile') ?>
      </a>

      <?php /* refs #15480 add password change to fid profile */ ?>

      <a href="<?= $this->url('fid/user/reset-password') ?>" data-lightbox>
        <span class="no-padding">
          <i class="icon icon-lock" aria-hidden="true"></i>
        </span>
        <?= $this->transEsc('Change Password') ?>
      </a>

      <a href="<?= $this->url('fid/user/change-username') ?>" data-lightbox>
        <span class="no-padding">
          <i class="icon icon-edit-3" aria-hidden="true"></i>
        </span>
        <?= $this->transEsc('fid::username_change_link') ?>
      </a>

      <a href="<?= $this->url('fid/user/delete') ?>" data-lightbox>
        <span class="no-padding">
          <i class="icon icon-trash-2" aria-hidden="true"></i>
        </span>
          <?= $this->transEsc('fid::user_delete_link') ?>
      </a>

        <?php /* refs #16033 contact link */ ?>
      <a href="<?= $this->url('feedback-home') ?>" data-lightbox>
        <span class="no-padding">
          <i class="icon icon-mail" aria-hidden="true"></i>
        </span>
        <?= $this->transEsc('contact_adlr') ?>
      </a>

      <span class="logout-button">
        <a href="<?= $this->url('myresearch-logout') ?>">
          <span class="no-padding">
            <i class="icon icon-log-out" aria-hidden="true"></i>
          </span>
          <?= $this->transEsc("Logout") ?>
        </a>
      </span>

      <?php if ($user->libraryCardsEnabled()): ?>
        <a href="<?= $this->url('librarycards-home') ?>"
           <?= $this->active == 'librarycards' ? ' class="active"' : '' ?>>
          <i class="fa fa-fw fa-barcode" aria-hidden="true"></i> <?= $this->transEsc('Library Cards') ?>
        </a>
      <?php endif; ?>
    <?php endif; ?>
  </div>

  <?php if ($this->permission()->allowDisplay('fid.ReadList')): ?>
    <br/>
    <h4><?=$this->transEsc('fid::admin_section')?></h4>
    <div class="myresearch-menu">
      <a href="<?=$this->url('fid/admin/list')?>"><?=$this->transEsc('fid::permission_read_user_list')?></a>
      <a href="<?=$this->url('fid/admin/orders')?>"><?=$this->transEsc('fid::permission_read_order_list')?></a>
    </div>
  <?php endif; ?>
  <!-- fid-adlr: myresearch - menu - END -->
<?php endif; ?>