Coded something up in Couch in an interesting way? Have a snippet or shortcode to share? Post it here for the community to benefit.
4 posts Page 1 of 1
Hey Couchers!

I'm configuring a site where the user will allow the changing of images, but not wanting users to upload any new ones.

On line 37 of couch/includes/kcfinder/config.php I changed 'upload' to false and that removed the option to upload for kcfinder.

I tried to search for this solution on this forum, but I didn't see anything, so I thought I'd put this in tips and ticks in case anyone else needed this information.

One question, can this setting be toggled per k_user_access_level?
It is possible to have a lot more than just tweaking "Upload". Requires an addon though to have that configurable per member

KCFinder Permissions.png
KCFinder Permissions.png (23.64 KiB) Viewed 879 times
Join COUCH:TALK channel here https://t.me/couchcms_chat
Donate to support my efforts to help the community https://boosty.to/trendo/donate
Thank you @trendoman. You do a lot of work in Couch and your solutions are inspiring.

Your solution here appears to be a 'per user' method. I'm wondering if these permissions can be set via authentication level.

For instance, the user has to be a level 7 or above to be able to see the 'upload' button.

Can this be done as a custom theme? In other words, would it be possible to create 2 kcfinder/config.php files and have either one implement based on the user's authentication level?
It's not that hard to craft a two-line solution. The outline —

in KCFinder's config, make an edit to ask the setting become dependable on a new global-scale constant, such as

Code: Select all
'upload' => !defined('K_KC_FINDER_NO_UPLOAD_FILES'),


If you define this constant for your (say, level 7) user with any value so that it just becomes known to the PHP (an example how we define constants is in Couch config and elsewhere), then once that user fires KCFinder, the state of definition will kick in.

It's a kind of simple flag which won't break things if the constant is not defined. The negation in the code line above means that if constant is not defined anywhere for current user then the upload setting becomes true and if constant is defined then it setting becomes false, so make sure to write a condition to have that defined.

On every couch-powered page reload, be it in frontend or in admin panel, all code runs again, so it does not mean that the setting becomes persistent, on the contrary it will be defined/undefined depending on your condition on each page load. A good file to place that condition is kfunctions.php.

P.S. You have said to utilize simple-access-control addon, so maybe you could add a condition there, but probably it is not a great idea :)
Join COUCH:TALK channel here https://t.me/couchcms_chat
Donate to support my efforts to help the community https://boosty.to/trendo/donate
4 posts Page 1 of 1
cron