You are here

function template_preprocess_filedepot_mainpage in filedepot 7

File

./filedepot.module, line 1854
filedepot.module Filedepot: File Management Module developed by Nextide www.nextide.ca Full featured document managment module with a desktop application feel. Integrated Organic Group, Role and User permissions to secure folders, automated…

Code

function template_preprocess_filedepot_mainpage(&$variables) {
  global $base_url, $user;
  $filedepot = filedepot_filedepot();
  if ($filedepot->ogmode_enabled and $filedepot->ogrootfolder > 0 and !$filedepot
    ->checkPermission($filedepot->ogrootfolder, 'view')) {
    drupal_set_message(t('You do not have access to this groups documents'), 'error');
    drupal_goto();
  }
  module_load_include('php', 'filedepot', 'lib-common');

  // Include the CTools tools that we need.
  ctools_include('ajax');
  ctools_include('modal');
  drupal_add_js(array(
    'filedepot-newfile-dialog-style' => array(
      'modalSize' => array(
        'type' => 'fixed',
        'width' => 650,
        'height' => 500,
      ),
      'modalOptions' => array(
        'opacity' => 0.6,
        'background' => '#333333',
      ),
      'closeText' => t('Close'),
    ),
  ), 'setting');
  drupal_add_js(array(
    'filedepot-newfolder-dialog-style' => array(
      'modalSize' => array(
        'type' => 'fixed',
        'width' => 625,
        'height' => 330,
      ),
      'modalOptions' => array(
        'opacity' => 0.6,
        'background' => '#333333',
      ),
      'closeText' => t('Close'),
    ),
  ), 'setting');

  // Add CTools' javascript to the page.
  ctools_modal_add_js();
  if (isset($variables['cid'])) {
    $folderid = $variables['cid'];
  }
  elseif (isset($_GET['cid'])) {
    $folderid = $_GET['cid'];
  }
  elseif (!isset($_GET['cid'])) {
    $folderid = 0;
  }
  if (!isset($_GET['fid'])) {
    $_GET['fid'] = 0;
  }
  $variables['yui_base_url'] = variable_get('filedepot_yui_baseurl', 'http://yui.yahooapis.com/2.7.0/build/');
  $variables['title'] = '';
  $variables['initialfid'] = intval($_GET['fid']);
  $variables['initialcid'] = intval($folderid);
  $variables['initialop'] = '';
  $variables['initialparm'] = '';
  $variables['site_url'] = $base_url;
  $variables['ajax_server_url'] = url('filedepot_ajax');
  $variables['filedepot_download_archive_url'] = url('filedepot_download_archive');
  $variables['actionurl_dir'] = base_path() . drupal_get_path('module', 'filedepot');
  $variables['filedepot_javascript_url'] = base_path() . drupal_get_path('module', 'filedepot') . '/js/';
  if (!user_is_logged_in()) {
    $variables['alert_message'] = 'You are not Logged in';
    $variables['show_alert'] = 'none';
  }
  else {
    $variables['alert_message'] = '';
    $variables['show_alert'] = 'none';
  }
  $variables['toolbarform'] = theme('filedepot_toolbar_form');

  // Set the session id to address a bug with Firefox and Mozilla with the YUI Uploader not posting $_COOKIES
  $variables['session_id'] = db_query("SELECT sid FROM {sessions} WHERE uid = :uid", array(
    ':uid' => $user->uid,
  ))
    ->fetchField();
  $variables['tagcloud'] = theme('filedepot_tagcloud');
  $adminFolders = filedepot_recursiveAccessOptions('admin');
  $uploadFolders = filedepot_recursiveAccessOptions(array(
    'upload',
    'upload_dir',
  ));
  if (!empty($adminFolders)) {
    $variables['show_newfolder'] = 'true';
  }
  elseif ($filedepot->ogmode_enabled and $filedepot
    ->checkPermission($filedepot->ogrootfolder, 'admin')) {
    $variables['show_newfolder'] = 'true';
  }
  else {
    $variables['show_newfolder'] = 'false';
  }
  if (empty($uploadFolders)) {
    $variables['show_upload'] = 'false';
  }
  else {
    $variables['show_upload'] = 'true';
  }
}