You are here

function imagepicker_admin_import in Image Picker 7

Same name and namespace in other branches
  1. 6.2 imagepicker.admin.inc \imagepicker_admin_import()
1 string reference to 'imagepicker_admin_import'
imagepicker_menu in ./imagepicker.module
Implement hook_menu().

File

./imagepicker.admin.inc, line 1692
@author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Code

function imagepicker_admin_import() {
  drupal_add_css(IMAGEPICKER_PATH . '/imagepicker.css');
  module_load_include('inc', 'imagepicker', 'imagepicker.import');
  if (!arg(4)) {
    imagepicker_variable_del('imagepicker_currentuser');
  }
  $uid = imagepicker_variable_get('imagepicker_currentuser', '');
  if (arg(4) == 'user' && is_numeric(arg(5))) {
    $uid = arg(5);
  }
  $content = "";
  if (!($importdir = imagepicker_variable_get('imagepicker_import_dir', ''))) {
    drupal_set_message(t('You need to set the import folder'));
  }
  $form = drupal_get_form('imagepicker_import_dir_form');
  $content = render($form);
  if ($importdir) {
    if ($import_files = imagepicker_import_dir_check()) {
      $form = drupal_get_form('imagepicker_user_search_form', 'import');
      $content .= render($form);
      if ($uid) {
        $account = user_load($uid);
        $form = drupal_get_form('imagepicker_import_form', count($import_files), $account, TRUE);
        $content .= render($form);
      }
      else {
        drupal_set_message(t('Please select a user. You have %total files to be imported', array(
          '%total' => count($import_files),
        )));
      }
    }
  }
  if (isset($_SESSION['imagepicker_import_status'])) {
    drupal_get_messages('status', TRUE);
    drupal_set_message($_SESSION['imagepicker_import_status']);
    unset($_SESSION['imagepicker_import_status']);
  }
  return $content;
}