home | career | drupal | java | mac | mysql | perl | php | scala | uml | unix

Drupal example source code file (imce.core.profiles.inc)

This example Drupal source code file (imce.core.profiles.inc) is included in the DevDaily.com "Drupal Source Code Warehouse" project. The intent of this project is to help you "Learn Drupal by Example".

PHP - Drupal tags/keywords

array, as, dimensions, foreach, function, isset, language, php, profiles, return, translate, true

The imce.core.profiles.inc Drupal example source code

<?php

/**
 * @file
 * Creates the default configuration profiles.
 */

/**
 * Create core profiles.
 */
function imce_install_profiles() {
  $profiles = variable_get('imce_profiles', array());

  //already installed
  if (isset($profiles[1]) && !empty($profiles[1])) {
    return TRUE;
  }

  $profiles[1] = imce_user1_profile();
  $profiles[2] = imce_sample_profile();
  variable_set('imce_profiles', $profiles);

  return TRUE;
}

/**
 * Construct a profile based on arguments.
 */
function imce_construct_profile($n, $u, $f, $q, $tq, $e, $d, $fn, $ds, $ts) {
  $profile = array('name' => $n, 'usertab' => $u, 'filesize' => $f, 'quota' => $q, 'tuquota' => $tq, 'extensions' => $e, 'dimensions' => $d, 'filenum' => $fn, 'directories' => array(), 'thumbnails' => array());
  foreach ($ds as $d) {
    $profile['directories'][] = array('name' => $d[0], 'subnav' => $d[1], 'browse' => $d[2], 'upload' => $d[3], 'thumb' => $d[4], 'delete' => $d[5], 'resize' => $d[6]);
  }
  foreach ($ts as $t) {
    $profile['thumbnails'][] = array('name' => $t[0], 'dimensions' => $t[1], 'prefix' => $t[2], 'suffix' => $t[3]);
  }
  return $profile;
}

/**
 * User1's profile.
 */
function imce_user1_profile() {
  $profiles = variable_get('imce_profiles', array());
  if (isset($profiles[1])) {
    return $profiles[1];
  }
  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_', '')));
}

/**
 * Default profile.
 */
function imce_sample_profile() {
  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_', '')));
}

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal imce.core.profiles.inc source code file:

new blog posts

"Drupal" is a registered trademark of Dries Buytaert.

my drupal tutorials and examples  

Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

Beginning in 2016, a portion of the proceeds from pages under the '/drupal-code-examples/' URI will be donated to charity.