You are here

function gallery_assist_install in Gallery Assist 7

Same name and namespace in other branches
  1. 6 gallery_assist.install \gallery_assist_install()

Implements hook_install()

File

./gallery_assist.install, line 421
Install, update and uninstall functions for the Gallery Assist module.

Code

function gallery_assist_install() {
  $t = get_t();

  // Add the node type.
  _gallery_assist_install_type_create();

  // Create the users gallery_assist directory if the user has the right permission.
  $path = file_default_scheme() . '://gallery_assist';
  if (file_prepare_directory($path, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
    drupal_set_message($t("The Gallery Assist enviroment has been created sucessfull."));
    watchdog('action', $t('The Gallery Assist enviroment has been created sucessfull.'));
  }
  else {
    drupal_set_message($t("It was not possible to create the gallery folder. Check file permissions, umask settings etc."), 'error');
    watchdog('error', $t('It was not possible to create the gallery folder. Check file permissions, umask settings etc.'));
  }
  variable_set('gallery_assist_directory', $path);

  // Create at install the gallery enviroment from super-user and from installator.
  $upath = variable_get('gallery_assist_directory', false) . '/' . 1;
  if (file_prepare_directory($upath, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
    watchdog('info', t('Gallery enviroment for the "super-admin" has bin created successfull.'));
    global $user;
    if ($user->uid != 1) {
      $path = $settings['ga']['ga_directory'] . '/' . $user->uid;
      if (file_prepare_directory($path, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
        watchdog('info', t('Gallery enviroment for user @user was created successfull.', array(
          '@user',
          $user->name,
        )));
      }
      else {
        watchdog('error', $t('It was not possible to create the user galleries folder. Check file permissions, umask settings etc.'));
      }
    }
  }
  else {
    watchdog('error', $t('It was not possible to create the user galleries folder. Check file permissions, umask settings etc.'));
  }

  // One of the basic features of this module is the assign gallery-funktionality.
  // The set the variable at this point is the best method to develop efecctiv and simplified module code.
  // (I mean with this the Assignment-Functionality)
  module_load_include('inc', 'gallery_assist', 'gallery_assist_variables');
  variable_set('gallery_assist_directory', $path);
  variable_set('gallery_assist_default', 1);
  variable_set('gallery_assist_default_data', gallery_assist_default_settings());
  watchdog('action', $t('The module Gallery Assist has bin installed sucessfull.'));
}