frontend/models/ShApi.php
/**
     * Check integrity BD content for Self-Hosted
     * @return array
     */
Check integrity BD content for Self-Hosted
@return array
Check integrity BD content for Self - Hosted @return array
public static function check_sh_system_integrity()
    {
        unset($checkUsers);
        $checkUsers = Users::findAll(['license_type' => [
            Licenses::TYPE_FREE_TRIAL,
            Licenses::TYPE_PAYED_PROFESSIONAL,
        ]]);
        if (sizeof($checkUsers) > 0) {
            Yii::$app->session->set('system-fault-error', 'contains-prohibited-types-license');
            Yii::$app->cache->delete('last_license_check');
            return [
                'status' => false,
                'info'   => "contains-prohibited-types-license",
            ];
        }
        unset($checkUsers);
        $checkUsers = Users::findAll(['license_type' => Licenses::TYPE_PAYED_BUSINESS_ADMIN]);
        if (sizeof($checkUsers) > 1) {
            Yii::$app->session->set('system-fault-error', 'more-then-one-business-admin-for-sh');
            Yii::$app->cache->delete('last_license_check');
            return [
                'status' => false,
                'info'   => "more-then-one-business-admin-for-sh"
            ];
        } elseif ($checkUsers === null || sizeof($checkUsers) == 0) {
            Yii::$app->session->set('system-fault-error', 'no-business-admin-user-in-db-for-sh');
            Yii::$app->cache->delete('last_license_check');
            return [
                'status' => false,
                'info'   => "no-business-admin-user-in-db-for-sh",
            ];
        }
        Yii::$app->cache->set('sh_integrity_passed', true, self::INTEGRITY_CHECK_TTL);
        return [
            'status' => true,
            'user'   => $checkUsers[0],
            'info'   => "sh_integrity_passed",
        ];
    }
public static function check_sh_system_integrity ( ) { unset ( $ checkUsers ) ; $ checkUsers = Users :: findAll ( [ 'license_type' => [ Licenses :: TYPE_FREE_TRIAL , Licenses :: TYPE_PAYED_PROFESSIONAL , ] ] ) ; if ( sizeof ( $ checkUsers ) > 0 ) { Yii :: $ app -> session -> set ( 'system-fault-error' , 'contains-prohibited-types-license' ) ; Yii :: $ app -> cache -> delete ( 'last_license_check' ) ; return [ 'status' => false , 'info' => " contains-prohibited-types-license " , ] ; } unset ( $ checkUsers ) ; $ checkUsers = Users :: findAll ( [ 'license_type' => Licenses :: TYPE_PAYED_BUSINESS_ADMIN ] ) ; if ( sizeof ( $ checkUsers ) > 1 ) { Yii :: $ app -> session -> set ( 'system-fault-error' , 'more-then-one-business-admin-for-sh' ) ; Yii :: $ app -> cache -> delete ( 'last_license_check' ) ; return [ 'status' => false , 'info' => " more-then-one-business-admin-for-sh " ] ; } elseif ( $ checkUsers === null || sizeof ( $ checkUsers ) == 0 ) { Yii :: $ app -> session -> set ( 'system-fault-error' , 'no-business-admin-user-in-db-for-sh' ) ; Yii :: $ app -> cache -> delete ( 'last_license_check' ) ; return [ 'status' => false , 'info' => " no-business-admin-user-in-db-for-sh " , ] ; } Yii :: $ app -> cache -> set ( 'sh_integrity_passed' , true , self :: INTEGRITY_CHECK_TTL ) ; return [ 'status' => true , 'user' => $ checkUsers [ 0 ] , 'info' => " sh_integrity_passed " , ] ; }
Check integrity BD content for Self-Hosted
 @return array
Check integrity BD content for Self - Hosted @return array
/* если это сх, то нужно проверить в БД наличие юзеров с лицензией отличной от бизнес-админ и бизнес-юзер, если есть - ошибка*/ /* если это сх, то нужно проверить в БД количество бизнес-админов если больше одного то выдать ошибку системы (это хак) */ /**/