Let get this simple, I plan to build a web app that will let the users (there's a dozen of them) upload images to the system. Every upload would be registered to the DB, including the image path and the user id.
What I want, is when I click the little image icon on the editor to add an image to my text (assuming that the user already uploaded his file), instead of having ( Browse the server ) has button have a drop-down list with the images belonging to the current logged user OR keep the Browse the server button and only show the user files, is that possible?
In the same time, is it possible to modify the upload tab to register the new image upload with his path and the sender id? I mean, does CKFinder really list the directories or retrieve his informations from a DB?
At least, if all of this doesn't work, is there an alternative to add images to the editor like I want?
What I want, is when I click the little image icon on the editor to add an image to my text (assuming that the user already uploaded his file), instead of having ( Browse the server ) has button have a drop-down list with the images belonging to the current logged user OR keep the Browse the server button and only show the user files, is that possible?
In the same time, is it possible to modify the upload tab to register the new image upload with his path and the sender id? I mean, does CKFinder really list the directories or retrieve his informations from a DB?
At least, if all of this doesn't work, is there an alternative to add images to the editor like I want?
Re: Can I modify CKFinder to show only images uploaded by the us
At this moment, the only way to customize the Link/Image dialog box in FCKeditor is to change html files used by FCKeditor:
- editor/dialog/fck_image.html
- editor/dialog/fck_link.html.
To link each file with the user using some kind fo a database, you would have to alter the code of server connector in CKFinder. For example if you're working on PHP5, take a look into the following directory: core/connector/php/php5
In CommandHandler/FileUpload.php you can inject your code that will be executed when file is uploaded (use sesion variables to get the user id).
Much more simple approach would be to tell CKFinder to use different directories for each user (by setting baseUrl/baseDir variables dynamically depending on a session variable for example). This way all you would have to do is to adjust the dialog files used by FCKeditor.
Wiktor Walc
CTO, CKSource - http://cksource.com
--
Follow CKEditor on: Twitter | Facebook | Google+
Re: Can I modify CKFinder to show only images uploaded by the us
ex.
user1 = /public_html/users/user1/
user2 = /public_html/users/user2/
user3 = /public_html/users/user3/
etc.
???
Can CKFinder compute the remaining space availaible too?
ex.: limit for all of them = 10 mo
user1 = 10 Mo remaining in /public_html/users/user1/
user2 = 7.2 Mo remaining in /public_html/users/user2/
user1 = 0.5 Mo remaining in /public_html/users/user3/
I mean, each user would have the same quota (10 Mo) and when they reaches that limit, upload fails with ERROR MSG printing out on the page. That size computing would compute all what the user folder contains (pdf, exe, doc, zip, images, flash, etc.), after reaching the limit, no more uploads.
And if it works, what happens? if a user only has 1 Mo remaining and tries to upload a 2 Mo file, what happens?
Do I have to change a lot of files to make CKFinder works like this? That would be really ... really great !!!
Thanks for the replies if any.
Re: Can I modify CKFinder to show only images uploaded by the us
You don't have to create them manually, all you have to do is to set different baseurl/basedir variables, CKFinder will create these folders automatically.
To limit quota you would have to add your code to the server connector, take a look here for an idea on how to implement it in ASP.NET:
viewtopic.php?f=10&t=12840&p=33584&hilit=quota#p33584
Basically, you need to modify the code of FileUpload command handler and calcuate directory size before deciding whether the file can be saved or not.
Wiktor Walc
CTO, CKSource - http://cksource.com
--
Follow CKEditor on: Twitter | Facebook | Google+
Re: Can I modify CKFinder to show only images uploaded by the us
I don't know what you mean ... CKFinder will create folders automatically based on what? baseurl/basedir variables?? Where I specifiy those, in a config file? If yes, how can this be dynamic? When, let's say, I create a user via an admin section (exp.: homer), I want a folder to be created in /public_html/users/homer/ where user 'homer' will dump his files. He won't have access to anywhere else, just /homer.
What if the folder already exists?
For the limit quota, I'm in PHP, is it possible too?
If found this code that seems to work (I tried it), but could this be easily implemented in CKFinder?
Thanks
Re: Can I modify CKFinder to show only images uploaded by the us
Yes, you'll find them in the configuration file (config.php).
You can use $_SESSION variables. For example when user logs in, execute the following code
In config.php set:
(remember about calling session_start();).
CKFinder will simply use this folder.
Yes, in a very similar way, but note that its not a built-in feature, you need to code it.
Probably, you'll need to modify the following files:
core\connector\php\php*\CommandHandler\FileUpload.php
+ core\connector\php\constants.php (add error 550 CKFINDER_CONNECTOR_ERROR_EXCEEDS_QUOTA or something like that)
+ language file (core/lang)
I didn't test this particular command, but "du" command will work only on unix system, it may not work if you don't specify the full path to this command (/usr/bin/du or something like that) and last but not least shell_exec may be disabled in php.ini, especially if you're working on a shared host.
So an alternative solution would be to calculate the directory size in PHP (opendir + readdir + filesize), for sample functions take a look at user comments: http://php.net/stat or here http://php.net/function.filesize
Wiktor Walc
CTO, CKSource - http://cksource.com
--
Follow CKEditor on: Twitter | Facebook | Google+