<?php

/**
 * @file
 * Installs, uninstalls IMCE Crop.
 */

/**
 * Implements hook_install().
 */
function imce_crop_install() {
  $profiles = variable_get('imce_profiles', array());
  // Set crop permissions. Make profile#1 have access by default.
  foreach ($profiles as $i => $profile) {
    foreach ($profile['directories'] as $j => $directory) {
      $profiles[$i]['directories'][$j]['crop'] = $i == 1 ? 1 : 0;
    }
  }
  variable_set('imce_profiles', $profiles);
}

/**
 * Implements hook_uninstall().
 */
function imce_crop_uninstall() {
  $profiles = variable_get('imce_profiles', array());
  // Delete crop permissions.
  foreach ($profiles as $i => $profile) {
    foreach ($profile['directories'] as $j => $directory) {
      unset($profiles[$i]['directories'][$j]['crop']);
    }
  }
  variable_set('imce_profiles', $profiles);
}