View Issue Details

This bug affects 1 person(s).
 8
IDProjectCategoryView StatusLast Update
06414Bug reportsSurvey editingpublic2012-08-16 10:23
Reportersammousa Assigned Toc_schmitz  
PrioritynormalSeveritypartial_block 
Status closedResolutionfixed 
Product Version2.00RC7 
Target Version2.00RC9Fixed in Version2.00RC9 
Summary06414: Can't upload image during survey design.
Description

Can't upload image during survey design.

(Part of the) problem is in ./application/controllers/admin/kcfinder.php

The index function checks for file existence, the paths used however are incomplete (ie. it uses a relative path that starts with / making it absolute and thus the file is not found).

Steps To Reproduce

Install latest version from github create a new survey, add a question.
Try to add an image to the question text.

TagsNo tags attached.
Bug heat8
Complete LimeSurvey version number (& build)000000
I will donate to the project if issue is resolvedNo
BrowserFF
Database type & versionmysql 5.5.24-0ubuntu0.12.04.1
Server OS (if known)Ubuntu 12.04
Webserver software & version (if known)nginx 1.1.19-1
PHP Version5.4

Relationships

related to 06432 closedsammousa Unable to insert picture in question text 

Users monitoring this issue

There are no users monitoring this issue.

Activities

sammousa

sammousa

2012-08-01 12:27

reporter   ~20099

Last edited: 2012-08-01 12:28

Seems to the underlying problem stems from an incorrect variable used. Yii::app()->getConfig('generalscripts') returns a URL relative to the root domain.
When including php files of course a path relative to the file system should be used. I've (partly) solved this by introdoucing a new variable in config-defaults.php: $config['generalscriptspath'] = $config['rootdir'] .'/scripts/';

Which uses the root dir instead of the base url. Furthermore the method of inclusion only works for the PHP files; all assets like javascript files and images do not work.

I think this controller should be rewritten to be more structured:

  • Separate function for initiating kcfinder configuration.
  • Passthrough function that checks if a file is a php file, if so execute it.
  • If the file exists and is not a php file return the file.
Mazi

Mazi

2012-08-01 14:49

updater   ~20100

Last edited: 2012-08-01 14:51

I can partly reproduce the problem. When trying to upload an image and clicking the "search server" button, I see the Limesurvey root page ("the following surveys are available:..."), URL is http://localhost/git/dev/Limesurvey/admin/kcfinder/index/load/browse?type=images&CKEditor=description_en&CKEditorFuncNum=2&langCode=de

If I select a file from my local PC and click upload, the system also show part of the Limesurvey root page on top of the window (hard to recognize).

sammousa

sammousa

2012-08-02 13:57

reporter   ~20115

So i've been looking at the code and to me it seems a very complex solution to a relatively simple problem.

-- First of all there is the general issue of including 3rd party libraries (like kcfinder) without changing them.
-- Second there is the need to set some variables before referring the user to the libary files.

In my opinion we should not separate any files inside the library; ie. the separation between js / css assets and php scripts should not be applied since the code base is not part of limesurvey.

A solution that in my opinion is the nicest is to create a /vendors directory. (I'm aware of some of the other existing directories /application/third_party)
In this vendors directory we place a kcfinder directory which contains the library.

The complex kcfinder action (/application/controllers/admin/kcfinder.php can now be replaced with the following trivial code:
function index()
{
$this->initializeSession();
$match = '/admin/kcfinder/index/load/';
$replace = '/vendors/kcfinder/';
$url = str_replace($match, $replace, $_SERVER['REQUEST_URI']);
$this->getController()->redirect($url);
}

Note that initializeSession contains the existing code for setting variables in the session.

By using a redirect we are free of all the annoying asset-rewriting stuff. Furthermore we should, in my opinion, not use include on php files that are not meant to be included. (kcfinder uses session_start for example which results in errors since a session is already started by Yii)

Another advantage of such a strict separation is that it becomes easier to upgrade kcfinder.

--> I can create a fix in git and generate a pull request.

--> Someone should create a post about the directory layout and the intentions behind it... It is hard for developers new to limesurvey development to contribute without constantly knowing these design decisions.

sammousa

sammousa

2012-08-06 14:33

reporter   ~20224

This is fixed in my fork, along with some other changes:

  • New vendors directory for 3rd party libraries.
  • Removed kcfinder controller and added the necessary code to the htmleditor helper instead.

-- Regression:
CKEditor now always shows 3 toolbars, in both minimized and maximized mode. The old behavior required a lot of "hacks" which does not allow us to easily update the library. Since the wanted functionality of switching from 1 to 3 bars on maximize is on their roadmap this can be easily added when they release a new verison of the library.

abita1

abita1

2012-08-07 15:38

reporter   ~20248

"Someone should create a post about the directory layout and the intentions behind it... It is hard for developers new to limesurvey development to contribute without constantly knowing these design decisions."

Sam: I'll second that !

Mazi

Mazi

2012-08-07 16:38

updater   ~20251

Our manual is a wiki, everyone can edit and extend it. Please create a new page at http://docs.limesurvey.org/LimeSurvey+2.x+development+documentation and sum up your findings there.

Thanks!

sammousa

sammousa

2012-08-07 17:58

reporter   ~20252

Mazi, can you plz give me permissions to edit stuff? It seems i dont belong to everyone =(

Mazi

Mazi

2012-08-07 22:02

updater   ~20264

Hmm... usually you only need to create an account on limesurvey.org and when then being logged in there and clicking on "documentation", you should be logged in at the wiki automatically.
If this doesn't work, please quote the error message and provide your username and we'll have a look.
Thanks!

sammousa

sammousa

2012-08-07 23:15

reporter   ~20265

errorsError
You do not have permission to edit this page.

I am logged in, username: sammousa

Mazi

Mazi

2012-08-08 08:56

updater   ~20273

c_schmitz, please assign wiki user "sammousa" rights to add articles at the development section of the wiki.

Mazi

Mazi

2012-08-08 09:12

updater   ~20274

sammousa, please try again now, we have changed your rights.

sammousa

sammousa

2012-08-09 15:12

reporter   ~20311

works! can be closed since this code is in RC8.

c_schmitz

c_schmitz

2012-08-16 10:23

administrator   ~20478

Version 2.00 RC 9 released.

Issue History

Date Modified Username Field Change
2012-08-01 10:48 sammousa New Issue
2012-08-01 12:27 sammousa Note Added: 20099
2012-08-01 12:28 sammousa Note Edited: 20099
2012-08-01 14:49 Mazi Note Added: 20100
2012-08-01 14:49 Mazi Assigned To => c_schmitz
2012-08-01 14:49 Mazi Status new => assigned
2012-08-01 14:51 Mazi Note Edited: 20100
2012-08-02 13:57 sammousa Note Added: 20115
2012-08-04 13:42 c_schmitz Assigned To c_schmitz => sammousa
2012-08-06 14:29 sammousa Relationship added related to 06432
2012-08-06 14:33 sammousa Note Added: 20224
2012-08-07 11:16 c_schmitz Status assigned => resolved
2012-08-07 11:16 c_schmitz Fixed in Version => 2.00+
2012-08-07 11:16 c_schmitz Resolution open => fixed
2012-08-07 15:38 abita1 Note Added: 20248
2012-08-07 16:38 Mazi Note Added: 20251
2012-08-07 17:58 sammousa Note Added: 20252
2012-08-07 22:02 Mazi Note Added: 20264
2012-08-07 23:15 sammousa Note Added: 20265
2012-08-08 08:56 Mazi Assigned To sammousa => c_schmitz
2012-08-08 08:56 Mazi Status resolved => assigned
2012-08-08 08:56 Mazi Note Added: 20273
2012-08-08 09:12 Mazi Note Added: 20274
2012-08-08 09:12 Mazi Assigned To c_schmitz => Mazi
2012-08-08 09:12 Mazi Status assigned => feedback
2012-08-09 15:12 sammousa Note Added: 20311
2012-08-09 15:12 sammousa Status feedback => assigned
2012-08-09 15:12 sammousa Status assigned => resolved
2012-08-09 15:12 sammousa Assigned To Mazi => c_schmitz
2012-08-12 15:32 c_schmitz Fixed in Version 2.00+ => 2.00RC9
2012-08-15 00:22 c_schmitz Target Version => 2.00RC9
2012-08-16 10:23 c_schmitz Note Added: 20478
2012-08-16 10:23 c_schmitz Status resolved => closed
2019-11-01 17:25 c_schmitz Category Survey design => Survey editing