Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Prevent admin edit of responses

  • ChristianSpartacus
  • ChristianSpartacus's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 9 months ago #122734 by ChristianSpartacus
Prevent admin edit of responses was created by ChristianSpartacus
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
The topic has been locked.
  • gabrieljenik
  • gabrieljenik's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
8 years 9 months ago #122736 by gabrieljenik
Replied by gabrieljenik on 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.

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

Checkout our Reporting Solutions and our plugin shop at www.encuesta.biz .

The topic has been locked.
  • ChristianSpartacus
  • ChristianSpartacus's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 9 months ago #122737 by ChristianSpartacus
Replied by ChristianSpartacus on 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?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 9 months ago #122738 by tpartner
Replied by tpartner on 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:
Code:
    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:
Code:
    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.
The topic has been locked.
  • ChristianSpartacus
  • ChristianSpartacus's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 9 months ago #122739 by ChristianSpartacus
Replied by ChristianSpartacus on topic Prevent admin edit of responses
Wow, thank you!! I really appreciate it!
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 9 months ago #122741 by DenisChenu
Replied by DenisChenu on 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 , plugin development .
I don't answer to private message.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose