You are here

function filedepotAjaxServer_generateLeftSideNavigation in filedepot 6

Same name and namespace in other branches
  1. 7 lib-ajaxserver.php \filedepotAjaxServer_generateLeftSideNavigation()
2 calls to filedepotAjaxServer_generateLeftSideNavigation()
filedepotAjaxServer_deleteFile in ./lib-ajaxserver.php
filedepot_dispatcher in ./ajaxserver.php
@file ajaxserver.php Implementation of filedepot_ajax() - main ajax handler for the module

File

./lib-ajaxserver.php, line 83
lib-ajaxserver.php Library functions for the ajax_server

Code

function filedepotAjaxServer_generateLeftSideNavigation($data = '') {
  global $user;
  $filedepot = filedepot_filedepot();
  if (empty($data)) {
    $data = array(
      'retcode' => 200,
    );
  }
  $approvals = filedepot_getSubmissionCnt();
  $data['reports'] = array();
  $data['topfolders'] = array();
  $data['reports'][] = array(
    'name' => t('Latest Files'),
    'link' => "reportmode=latestfiles",
    'parent' => 'allitems',
    'icon' => 'icon-filelisting',
  );
  if (user_is_logged_in()) {
    $data['reports'][] = array(
      'name' => t('Notifications'),
      'link' => "reportmode=notifications",
      'parent' => 'allitems',
      'icon' => 'icon-fileowned',
    );
    $data['reports'][] = array(
      'name' => t('Owned by me'),
      'link' => "reportmode=myfiles",
      'parent' => 'allitems',
      'icon' => 'icon-fileowned',
    );
    $data['reports'][] = array(
      'name' => t('Downloaded by me'),
      'link' => "reportmode=downloads",
      'parent' => 'allitems',
      'icon' => 'icon-fileowned',
    );
    $data['reports'][] = array(
      'name' => t('Unread Files'),
      'link' => "reportmode=unread",
      'parent' => 'allitems',
      'icon' => 'icon-fileowned',
    );
    $data['reports'][] = array(
      'name' => t('Locked by me'),
      'link' => "reportmode=lockedfiles",
      'parent' => 'allitems',
      'icon' => 'icon-filelocked',
    );
    $data['reports'][] = array(
      'name' => t('Flagged by me'),
      'link' => "reportmode=flaggedfiles",
      'parent' => 'allitems',
      'icon' => 'icon-fileflagged',
    );
  }
  if ($approvals > 0) {
    $approvals = " ({$approvals})";
    $data['reports'][] = array(
      'name' => t('Waiting approval') . "{$approvals}",
      'link' => "reportmode=approvals",
      'parent' => 'allitems',
      'icon' => 'icon-fileowned',
    );
  }
  if (user_is_logged_in()) {
    if (user_access('administer filedepot', $user)) {
      $res = db_query("SELECT COUNT(id) as incoming FROM {filedepot_import_queue}");
    }
    else {
      $res = db_query("SELECT COUNT(id) as incoming FROM {filedepot_import_queue} WHERE uid=%d", $user->uid);
    }
    $A = db_fetch_array($res);
    if ($A['incoming'] > 0) {
      $incoming_msg = " ({$A['incoming']})";
      $data['reports'][] = array(
        'name' => t('Incoming Files') . "{$incoming_msg}",
        'link' => "reportmode=incoming",
        'parent' => 'allitems',
        'icon' => 'icon-fileowned',
      );
    }
  }

  // Setup the Most Recent folders for this user
  if (user_is_logged_in()) {
    $sql = "SELECT a.id,a.cid,b.name FROM {filedepot_recentfolders} a ";
    $sql .= "LEFT JOIN {filedepot_categories} b ON b.cid=a.cid WHERE uid=%d ORDER BY id";
    $res = db_query($sql, $user->uid);
    while ($A = db_fetch_array($res)) {
      $data['recentfolders'][] = array(
        'name' => filter_xss($A['name']),
        'link' => "cid={$A['cid']}",
        'icon' => 'icon-allfolders',
      );
    }
  }
  $res = db_query("SELECT cid,pid,name,description from {filedepot_categories} WHERE pid='0' ORDER BY folderorder");
  while ($A = db_fetch_array($res)) {
    if ($filedepot
      ->checkPermission($A['cid'], 'view')) {
      $data['topfolders'][] = array(
        'name' => filter_xss($A['name']),
        'link' => "cid={$A['cid']}",
        'parent' => 'allfolders',
        'icon' => 'icon-allfolders',
      );
    }
  }
  if (function_exists(filedepot_customLeftsideNavigation)) {
    $data = filedepot_customLeftsideNavigation($data);
  }
  return $data;
}