| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: imce.core.profiles.inc,v 1.1.2.2 2010/08/18 01:40:23 ufku Exp $ 3 4 /** 5 * @file 6 * Creates the default configuration profiles. 7 */ 8 9 /** 10 * Create core profiles and import settings from 5.x 11 */ 12 function imce_install_profiles() { 13 14 //already installed 15 if (in_array(1, array_keys(variable_get('imce_profiles', array())))) { 16 return FALSE; 17 } 18 19 $profiles = array(1 => imce_user1_profile(), 2 => imce_sample_profile()); 20 $index = 2; 21 $role_profile = array(); 22 23 //import user-1 settings 24 if ($u1p = variable_get('imce_settings_user1', NULL)) { 25 $profiles[1]['dimensions'] = $u1p['width'] .'x'. $u1p['height']; 26 } 27 28 //role settings 29 $user_roles = user_roles(); 30 //determine weights 31 $weights = array(); 32 $sort = variable_get('imce_settings_rank', array()); 33 foreach ($sort as $i => $rid) { 34 if (isset($user_roles[$rid])) { 35 $weights[$rid] = $i-10; 36 } 37 } 38 39 //import role settings. 40 foreach (variable_get('imce_settings_roles', array()) as $rid => $set) { 41 if (isset($user_roles[$rid])) { 42 $dirs = $thumbs = array(); 43 44 //directories 45 $set['shared'] = $set['shared'] == '/' ? '.' : $set['shared']; 46 $dirs = array(array($set['shared'] == '' ? $set['prefix'] .'%uid' : $set['shared'], $set['subnav'] && $set['subdirs'] == '', 1, $set['upload'], $set['twidth'] && $set['theight'], $set['delete'], $set['resize'])); 47 48 //subdirectories 49 if ($set['subnav'] && $set['subdirs'] != '') { 50 foreach (explode(',', $set['subdirs']) as $subdir) { 51 $subdir = trim($subdir); 52 if ($subdir != '') { 53 $dirs[] = array($dirs[0][0] .'/'. $subdir, 0, 1, $set['upload'], $dirs[0][4], $set['delete'], $set['resize']); 54 } 55 } 56 } 57 58 //thumbnails 59 if ($set['twidth'] && $set['theight']) { 60 $thumbs = array(array('Thumbnail-1', $set['twidth'] .'x'. $set['theight'], '', '')); 61 } 62 63 //extensions 64 $ext = 'gif png jpg jpeg'; 65 $ext .= $set['extensions'] ? ' '. str_replace(array(',', '.', ' '), array(' ', '', ' '), $set['extensions']) : ''; 66 67 //file size - quota 68 $fsize = $set['nolimit'] ? 0 : round($set['filesize']/1024, 1); 69 $quota = $set['nolimit'] ? 0 : round($set['quota']/1024, 1); 70 71 //create profile 72 $profile_name = $user_roles[$rid]; 73 $profiles[$index] = imce_construct_profile($profile_name, 1, $fsize, $quota, 0, $ext, $set['width'] .'x'. $set['height'], 1, $dirs, $thumbs); 74 75 //assign the profile to the role. 76 $role_profile[$rid] = array('pid' => $index, 'weight' => $weights[$rid]); 77 $index++; 78 } 79 } 80 81 //delete old variables 82 variable_del('imce_settings_roles'); 83 variable_del('imce_settings_user1'); 84 variable_del('imce_settings_rank'); 85 variable_del('imce_settings_tinymce'); 86 variable_del('imce_settings_fck'); 87 88 //set new variables 89 variable_set('imce_profiles', $profiles); 90 variable_set('imce_roles_profiles', $role_profile); 91 92 return TRUE; 93 } 94 95 /** 96 * Construct a profile based on arguments. 97 */ 98 function imce_construct_profile($n, $u, $f, $q, $tq, $e, $d, $fn, $ds, $ts) { 99 $profile = array('name' => $n, 'usertab' => $u, 'filesize' => $f, 'quota' => $q, 'tuquota' => $tq, 'extensions' => $e, 'dimensions' => $d, 'filenum' => $fn, 'directories' => array(), 'thumbnails' => array()); 100 foreach ($ds as $d) { 101 $profile['directories'][] = array('name' => $d[0], 'subnav' => $d[1], 'browse' => $d[2], 'upload' => $d[3], 'thumb' => $d[4], 'delete' => $d[5], 'resize' => $d[6]); 102 } 103 foreach ($ts as $t) { 104 $profile['thumbnails'][] = array('name' => $t[0], 'dimensions' => $t[1], 'prefix' => $t[2], 'suffix' => $t[3]); 105 } 106 return $profile; 107 } 108 109 /** 110 * User1's profile. 111 */ 112 function imce_user1_profile() { 113 $profiles = variable_get('imce_profiles', array()); 114 if (isset($profiles[1])) { 115 return $profiles[1]; 116 } 117 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_', ''))); 118 } 119 120 /** 121 * Default profile. 122 */ 123 function imce_sample_profile() { 124 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_', ''))); 125 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |