Prevent admin edit of responses

More
3 years 3 months ago #122734 by ChristianSpartacus
ChristianSpartacus created the topic: Prevent admin edit of responses
I need to be able to configure an anonymous token-based closed survey so that the admin does not have the ability to edit responses through the admin UI.

Any other tips to help respondents be reasonably assured that there is not an easy way for someone to change their answers are welcome.

Thank you in advance!

-Christian

Please Log in or Create an account to join the conversation.

More
3 years 3 months ago #122736 by gabrieljenik
gabrieljenik replied the topic: Prevent admin edit of responses
Why not keeping the superadmin user for your own and giving the admin a user with limited permissions?

If not, you can always edit the source code to disable the editing.

Cheers,
Gabriel - www.Encuesta.Biz - Authorized Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Assistance on LimeSurvey forum and LimeSurvey core developpement are on my free time (Say thanks ?)....[img]

Please Log in or Create an account to join the conversation.

More
3 years 3 months ago #122737 by ChristianSpartacus
ChristianSpartacus replied the topic: Prevent admin edit of responses
Thank you!

Do you happen to know which source code file I would edit to prevent even the superadmin from having access to edit responses?

Please Log in or Create an account to join the conversation.

More
3 years 3 months ago #122738 by tpartner
tpartner replied the topic: Prevent admin edit of responses
This is a hack to entirely disable response editing. It needs to be tested and will be over-written on updates.

In /application/models/Permission.php, find this function:
    function hasSurveyPermission($iSurveyID,$sPermission, $sCRUD, $iUserID=null)
    {
        $oSurvey=Survey::Model()->findByPk($iSurveyID);
        if (!$oSurvey) 
            return false;
        $iUserID=self::getUserId($iUserID);
        if(!$iUserID)
            return false;
        // If you own a survey you have access to the whole survey
        if ($iUserID==$oSurvey->owner_id) 
            return true;
 
        // Get global correspondance for surveys rigth
        $sGlobalCRUD=($sCRUD=='create' || ($sCRUD=='delete' && $sPermission!='survey') ) ? 'update' : $sCRUD;
 
        return $this->hasGlobalPermission('surveys', $sGlobalCRUD, $iUserID) || $this->hasPermission($iSurveyID, 'survey', $sPermission, $sCRUD, $iUserID);
    }
And replace it with this:
    function hasSurveyPermission($iSurveyID,$sPermission, $sCRUD, $iUserID=null)
    {
        $oSurvey=Survey::Model()->findByPk($iSurveyID);
        if (!$oSurvey) 
            return false;
        $iUserID=self::getUserId($iUserID);
        if(!$iUserID)
            return false;
        // Entirely disable editing responses
        if($sPermission == 'responses' && ($sCRUD == 'create' || $sCRUD == 'update' || $sCRUD == 'delete'))
            return false;
        // If you own a survey you have access to the whole survey
        if ($iUserID==$oSurvey->owner_id) 
            return true;
 
        // Get global correspondance for surveys rigth
        $sGlobalCRUD=($sCRUD=='create' || ($sCRUD=='delete' && $sPermission!='survey') ) ? 'update' : $sCRUD;
 
        return $this->hasGlobalPermission('surveys', $sGlobalCRUD, $iUserID) || $this->hasPermission($iSurveyID, 'survey', $sPermission, $sCRUD, $iUserID);
    }

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in or Create an account to join the conversation.

More
3 years 3 months ago #122739 by ChristianSpartacus
ChristianSpartacus replied the topic: Prevent admin edit of responses
Wow, thank you!! I really appreciate it!

Please Log in or Create an account to join the conversation.

More
3 years 3 months ago #122741 by DenisChenu
DenisChenu replied the topic: Prevent admin edit of responses

tpartner wrote: This is a hack to entirely disable response editing. It needs to be tested and will be over-written on updates....

Hi Tony ,

With 2.06 : we have before Permission event manual.limesurvey.org/BeforeHasPermission .

I think this hack can be put it beforeHasPermission event in a plugin, no ?

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!