You are here

function filedepot_newfile_form in filedepot 7

1 string reference to 'filedepot_newfile_form'
filedepot_newfile_dialog in ./filedepot.module

File

./filedepot.module, line 2141
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 filedepot_newfile_form($form, &$form_state) {
  global $user;
  $filedepot = filedepot_filedepot();

  // Using the ctools cache functionality to save which folder the user has selected
  ctools_include('object-cache');
  $cid = ctools_object_cache_get('filedepot', 'folder');
  module_load_include('php', 'filedepot', 'lib-common');
  $default_filter = 'jpg png doc docx xls xlsx pdf ppt pptx';
  $filter = variable_get('filedepot_filetype_filter', $default_filter);
  $form['filedepot_file'] = array(
    '#type' => 'managed_file',
    '#title' => t('Choose a file'),
    '#size' => 22,
    '#upload_validators' => array(
      'file_validate_extensions' => array(
        $filter,
      ),
    ),
  );
  $form['filedepot_filename'] = array(
    '#type' => 'textfield',
    '#title' => t('Display Name'),
    '#size' => 34,
  );
  if ($filedepot->ogmode_enabled and $filedepot
    ->checkPermission($filedepot->ogrootfolder, 'admin')) {
    $parentFolders = array(
      $filedepot->ogrootfolder => t('Top Level Folder'),
    );
  }
  else {
    if (user_access('administer filedepot', $user)) {
      $parentFolders = array(
        0 => t('Top Level Folder'),
      );
    }
    else {
      $parentFolders = array();
    }
  }
  $parentFolders += filedepot_recursiveAccessArray(array(
    'upload_dir',
    'upload',
  ));
  $form['filedepot_parentfolder'] = array(
    '#type' => 'select',
    '#title' => t('Parent Folder'),
    '#required' => FALSE,
    '#options' => $parentFolders,
    '#default_value' => $cid,
  );
  $form['filedepot_filetags'] = array(
    '#type' => 'textfield',
    '#title' => t('Tags'),
    '#size' => 34,
  );
  $form['filedepot_description'] = array(
    '#type' => 'textarea',
    '#title' => t('Description'),
    '#rows' => 2,
  );
  $form['filedepot_version_note'] = array(
    '#type' => 'textarea',
    '#title' => t('Version Notes'),
    '#rows' => 2,
  );
  $form['filedepot_email_notification'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Email Notification'),
    '#options' => array(
      'yes' => t('Yes'),
    ),
    '#default_value' => array(
      'yes' => 'yes',
    ),
  );
  $form['buttons'] = array(
    '#prefix' => '<div style="text-align:center;">',
    '#suffix' => '</div>',
  );
  $form['buttons']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Upload File'),
  );
  $form['buttons']['cancel'] = array(
    '#type' => 'submit',
    '#access' => TRUE,
    '#value' => t('Cancel'),
    '#weight' => 60,
    '#submit' => array(
      'filedepot_ctools_form_cancel',
    ),
  );
  $form['buttons']['submit']['#submit'][] = 'filedepot_newfile_submit';
  $form['buttons']['submit']['#validate'][] = 'filedepot_newfile_validate';
  return $form;
}