HEX
Server: LiteSpeed
System: Linux d8 4.18.0-553.30.1.lve.el8.x86_64 #1 SMP Tue Dec 3 01:21:19 UTC 2024 x86_64
User: wbwebdes (3015)
PHP: 8.1.31
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: /home/wbwebdes/domains/survey.wb-webdesign.com/private_html/application/models/SurveysInGroup.php
<?php

/**
 * Class SurveysGroups
 * @inheritdoc
 * Used for Permission on survey inside group :
 *
 */
class SurveysInGroup extends SurveysGroups implements PermissionInterface
{
    use PermissionTrait;

    /**
     * Returns the static model of the specified AR class.
     * Please note that you should have this exact method in all your CActiveRecord descendants!
     * @param string $className active record class name.
     * @return SurveysGroups the static model class
     */
    public static function model($className = __CLASS__)
    {
        /** @var self $model */
        $model = parent::model($className);
        return $model;
    }

    /**
     * Get Permission data for Permission object
     * @param string $key
     * @return array
     */
    public static function getPermissionData()
    {
        $aPermission = array(
            'surveys' => array(
                'create' => false,
                'read' => true,
                'update' => true,
                'delete' => true,
                'import' => false,
                'export' => true,
                'title' => gT("Surveys in this group"),
                'description' => gT("Permission to access surveys in this group. To see a survey in the list the read/view permission must be given."),
                'img' => ' ri-file-edit-line',
            ),
        );
        return $aPermission;
    }

    /**
     * Get the owner id of this Survey group
     * Used for Permission
     * @return integer|null
     */
    public function getOwnerId()
    {
        if (!App()->getConfig('ownerManageAllSurveysInGroup')) {
            return null;
        }
        return $this->owner_id;
    }

    /**
     * @inheritdoc
     * No minimal permission : must be set or get it via owner (or global)
     */
    public static function getMinimalPermissionRead()
    {
        return null;
    }

    /**
     * @inheritdoc
     */
    public function hasPermission($sPermission, $sCRUD = 'read', $iUserID = null)
    {
        /* If have global for surveys : return true */
        $sGlobalCRUD = $sCRUD;
        if (($sCRUD == 'create' || $sCRUD == 'import')) { // Create and import (token, response , question content …) need only allow update surveys
            $sGlobalCRUD = 'update';
        }
        if (($sCRUD == 'delete' && $sPermission != 'survey')) { // Delete (token, response , question content …) need only allow update surveys
            $sGlobalCRUD = 'update';
        }
        /* Have surveys permission */
        if (Permission::model()->hasPermission(0, 'global', 'surveys', $sGlobalCRUD, $iUserID)) {
            return true;
        }
        /* Specific need gsid */
        if (!$this->gsid) {
            return false;
        }
        /* Finally : return specific one */
        return Permission::model()->hasPermission($this->gsid, 'surveysingroup', $sPermission, $sCRUD, $iUserID);
    }
}