Now we still have to allow user1 to control only folder1 and user2 to control only his own folder. We will achieve this by creating a dynamic resource type definition:
(if user is not authenticated, he will be redirected to 'unathenticated' folder in which he won't be allowed to perform any operation).
Remember that when using the configuration settings above, the two variables: $_SESSION['CKFinder_UserFolder'], $_SESSION['CKFinder_UserRole'] should be set after user logs in so that CKFinder could use them.
Re: How to have one and only one folder per user ?
In config.php add at the beginning
to have access to variables stored in the $_SESSION array.
Suppose that when user logs in, the following variables are set:
We can now create two access controls.
Deny access by default to unauthenticated users:
Allow everything for "users" group members:
Now we still have to allow user1 to control only folder1 and user2 to control only his own folder. We will achieve this by creating a dynamic resource type definition:
if (isset($_SESSION['CKFinder_UserFolder'],$_SESSION['CKFinder_UserRole'])) { $config['ResourceType'][] = Array( 'name' => 'All', 'url' => $baseUrl . $_SESSION['CKFinder_UserFolder'], 'directory' => $baseDir . $_SESSION['CKFinder_UserFolder'], 'maxSize' => "8M", 'allowedExtensions' => 'gif,jpg,txt,zip', 'deniedExtensions' => ''); }Note that the url/directory where CKFinder saves files depends on the session variable.
Wiktor Walc
CTO, CKSource - http://cksource.com
--
Follow CKEditor on: Twitter | Facebook | Google+
Re: How to have one and only one folder per user ?
Re: How to have one and only one folder per user ?
Alternatively, could you please send me a PM with your configuration file?
Wiktor Walc
CTO, CKSource - http://cksource.com
--
Follow CKEditor on: Twitter | Facebook | Google+
Re: How to have one and only one folder per user ?
<?php function CheckAuthentication() { return true; } $config['LicenseName'] = 'www.studiokalafunga.com'; $config['LicenseKey'] = ''; $baseUrl = '/fichiers/'; $baseDir = resolveUrl($baseUrl); $config['Thumbnails'] = Array( 'url' => $baseUrl . '_thumbs', 'directory' => $baseDir . '_thumbs', 'enabled' => true, 'directAccess' => false, 'maxWidth' => 100, 'maxHeight' => 100, 'bmpSupported' => false, 'quality' => 80); $config['Images'] = 0 ; $config['RoleSessionVar'] = 'CKFinder_UserRole'; $config['AccessControl'][] = Array( 'role' => '*', 'resourceType' => '*', 'folder' => '/', 'folderView' => true, 'folderCreate' => true, 'folderRename' => true, 'folderDelete' => true, 'fileView' => true, 'fileUpload' => true, 'fileRename' => true, 'fileDelete' => true); $config['AccessControl'][] = Array( 'role' => '*', 'resourceType' => '*', 'folder' => '/_thumbs', 'folderView' => false, 'folderCreate' => false, 'folderRename' => false, 'folderDelete' => false, 'fileUpload' => false, 'fileRename' => false, 'fileDelete' => false); $config['DefaultResourceTypes'] = 'files'; if ( isset($_SESSION['CKFinder_UserFolder'], $_SESSION['CKFinder_UserRole']) ) { $config['ResourceType'][] = Array( 'name' => 'files', // Single quotes not allowed 'url' => $baseUrl . $_SESSION['CKFinder_UserFolder'], 'directory' => $baseDir . $_SESSION['CKFinder_UserFolder'], 'maxSize' => 0, 'allowedExtensions' => '', 'deniedExtensions' => 'php,php3,php5,cgi,css'); } $config['CheckDoubleExtension'] = true; $config['FilesystemEncoding'] = 'UTF-8'; $config['SecureImageUploads'] = true; $config['CheckSizeAfterScaling'] = true; $config['HtmlExtensions'] = array('html', 'htm', 'xml', 'js'); $config['HideFolders'] = Array(".svn", "CVS"); $config['HideFiles'] = Array(".*"); $config['ChmodFiles'] = 0777 ; $config['ChmodFolders'] = 0755 ;Re: How to have one and only one folder per user ?
At the beginning of config file add:
to initialize $_SESSION variables.
In:
change role to 'users' to grant ACL access to users that belong to group "users".
And the last thing, it turned out that CKFinder needs at least one resource type definition to work, so the following code could be used instead:
if ( isset($_SESSION['CKFinder_UserFolder'], $_SESSION['CKFinder_UserRole']) ) { $config['ResourceType'][] = Array( 'name' => 'files', // Single quotes not allowed 'url' => $baseUrl . $_SESSION['CKFinder_UserFolder'], 'directory' => $baseDir . $_SESSION['CKFinder_UserFolder'], 'maxSize' => 0, 'allowedExtensions' => '', 'deniedExtensions' => 'php,php3,php5,cgi,css'); } else { $config['ResourceType'][] = Array( 'name' => 'files', // Single quotes not allowed 'url' => $baseUrl . 'unauthenticated', 'directory' => $baseDir . 'unauthenticated', 'maxSize' => 0, 'allowedExtensions' => '', 'deniedExtensions' => 'php,php3,php5,cgi,css'); }(if user is not authenticated, he will be redirected to 'unathenticated' folder in which he won't be allowed to perform any operation).
Remember that when using the configuration settings above, the two variables: $_SESSION['CKFinder_UserFolder'], $_SESSION['CKFinder_UserRole'] should be set after user logs in so that CKFinder could use them.
Wiktor Walc
CTO, CKSource - http://cksource.com
--
Follow CKEditor on: Twitter | Facebook | Google+
Re: How to have one and only one folder per user ?