TinyMCE, ImageManager, and Per-user image directories
nvahalik - April 4, 2006 - 21:27
Everything works great, but I'd like to have everything set up so that when a user uses the ImageManager, they have their own directory.
Has one done this or knows how feasible this is?

Me too
I really like this request. There is no reason that someone should see the files of someone else.
Andre
-------------------------------------------------
http://www.opentravelinfo.com
http://www.aguntherphotography.com
upload into subdir based on uid
user uploads into a subdir that is a filsystem-safe version of the user's name. (ie, if user "joe cool" uploads file "test.txt", it ends up in "files/joe_cool/test.txt"). see node:14790
Apache is bandwidth limited, PHP is CPU limited, and MySQL is memory limited.
Here is how I did it...
Okay, this is really hackish.. but it works for what i require:
This would be ~/modules/tinymce/tinymce/jscripts/tiny_mce/plugins/imagemanager/config.php
<?php
require_once('classes/Authenticators/DrupalAuthenticatorImpl.php');
// General settings
$mcImageManagerConfig['general.login_page'] = 'not_loggedin.php';
// File system settings
/* What you are witnessing here is a hack. Yes, a nasty bloody hack. */
$user_path = '../../../../../../../files/pictures/'.$user->uid;
if(!is_dir($user_path))
mkdir($user_path);
$mcImageManagerConfig['filesystem.path'] = $user_path;
$mcImageManagerConfig['filesystem.rootpath'] = $user_path;
$mcImageManagerConfig['authenticator'] = 'DrupalAuthenticatorImpl';
// Add edit button
$mcImageManagerConfig['thumbnail.image_tools'] = 'preview,info,delete,edit';
?>
Hm
Thanks for sharing. Basically if I replace ../../.. with the base_url I should be fine ;-)
Andre
-------------------------------------------------
http://www.opentravelinfo.com
http://www.aguntherphotography.com
Slightly modified version
Its slightly modified version it check for permission, if the user is uid 1 or has admin tinymce access, then he can access all the users folders if not the user will be accessed to his/her folder.
<?php
require_once('classes/Authenticators/DrupalAuthenticatorImpl.php');
// General settings
$mcImageManagerConfig['general.login_page'] = 'not_loggedin.php';
// File system settings
/* What you are witnessing here is a hack. Yes, a nasty bloody hack. */
/* check access permissions for the loggedin user */
if ((user_access('administer tinymce')) || ($user->uid == '1')){
$user_path = '../../../../../../../files/pictures';}
else {
$user_path = '../../../../../../../files/pictures/'.$user->uid;
}
if(!is_dir($user_path))
mkdir($user_path);
$mcImageManagerConfig['filesystem.path'] = $user_path;
$mcImageManagerConfig['filesystem.rootpath'] = $user_path;
$mcImageManagerConfig['authenticator'] = 'DrupalAuthenticatorImpl';
// Add edit button
$mcImageManagerConfig['thumbnail.image_tools'] = 'preview,info,delete,edit';
?>
Sunny
www.gleez.com | www.sandeepone.com
Modified with multisite support
It's a ugly hack but works with multisite, to work it on multiple subdomains.
This will work with multisite, however, it supports only absolute path in the default drupal admin settings. ex:/home/sitename/public_html/files
<?php
require_once('classes/Authenticators/DrupalAuthenticatorImpl.php');
// General settings
$mcImageManagerConfig['general.login_page'] = 'not_loggedin.php';
// File system settings
/* What you are witnessing here is a hack. Yes, a nasty bloody hack. */
if ((user_access('administer tinymce')) || ($user->uid == '1')){
$user_path = variable_get('file_directory_path', 'files').'/pictures/';}
else {
$user_path = variable_get('file_directory_path', 'files') .'/pictures/'.$user->uid;
}
if(!is_dir($user_path))
mkdir($user_path);
$mcImageManagerConfig['filesystem.path'] = $user_path;
$mcImageManagerConfig['filesystem.rootpath'] = $user_path;
$mcImageManagerConfig['authenticator'] = 'DrupalAuthenticatorImpl';
// Add edit button
$mcImageManagerConfig['thumbnail.image_tools'] = 'preview,info,delete,edit';
?>
Sunny
www.gleez.com | www.sandeepone.com
This doesn't work in my
This doesn't work in my installation.
But I don't have the DrupalAuthenticatorImpl.php file in my classes directory. Could that cause the problem?
Current Solution
Just wondering if this is still a good hack for say the 5.x version, or is there a better alternative?
Thanks!
also looking for the same
also looking for the same features but need it to work on drupal 6.1,does anybody know to upgrade the needed module ? thanks
----------
My Drupal site: Philippines Travel - Come and Visit the beautiful Philippine Paradise!
by SEOContest2008
Fixed That
Thanks,
All worked fine with this great support.
--------------------------------------------------------
Progressive Entire Web Solution