imce.core.profiles.inc 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * @file
  4. * Creates the default configuration profiles.
  5. */
  6. /**
  7. * Create core profiles.
  8. */
  9. function imce_install_profiles() {
  10. $profiles = variable_get('imce_profiles', array());
  11. //already installed
  12. if (isset($profiles[1]) && !empty($profiles[1])) {
  13. return TRUE;
  14. }
  15. $profiles[1] = imce_user1_profile();
  16. $profiles[2] = imce_sample_profile();
  17. variable_set('imce_profiles', $profiles);
  18. return TRUE;
  19. }
  20. /**
  21. * Construct a profile based on arguments.
  22. */
  23. function imce_construct_profile($n, $u, $f, $q, $tq, $e, $d, $fn, $ds, $ts) {
  24. $profile = array('name' => $n, 'usertab' => $u, 'filesize' => $f, 'quota' => $q, 'tuquota' => $tq, 'extensions' => $e, 'dimensions' => $d, 'filenum' => $fn, 'directories' => array(), 'thumbnails' => array());
  25. foreach ($ds as $d) {
  26. $profile['directories'][] = array('name' => $d[0], 'subnav' => $d[1], 'browse' => $d[2], 'upload' => $d[3], 'thumb' => $d[4], 'delete' => $d[5], 'resize' => $d[6]);
  27. }
  28. foreach ($ts as $t) {
  29. $profile['thumbnails'][] = array('name' => $t[0], 'dimensions' => $t[1], 'prefix' => $t[2], 'suffix' => $t[3]);
  30. }
  31. return $profile;
  32. }
  33. /**
  34. * User1's profile.
  35. */
  36. function imce_user1_profile() {
  37. $profiles = variable_get('imce_profiles', array());
  38. if (isset($profiles[1])) {
  39. return $profiles[1];
  40. }
  41. return imce_construct_profile('User-1', 1, 0, 0, 0, '*', '1200x1200', 0, array(array('.', 1, 1, 1, 1, 1, 1)), array(array('Small', '90x90', 'small_', ''), array('Medium', '120x120', 'medium_', ''), array('Large', '180x180', 'large_', '')));
  42. }
  43. /**
  44. * Default profile.
  45. */
  46. function imce_sample_profile() {
  47. return imce_construct_profile('Sample profile', 1, 1, 2, 0, 'gif png jpg jpeg', '800x600', 1, array(array('u%uid', 0, 1, 1, 1, 0, 0)), array(array('Thumb', '90x90', 'thumb_', '')));
  48. }