<commit_before><?php

namespace OCA\Group_Custom;

class Helper {
    /**
     * Verify if prefix is enabled (see general settings screen, "Custom Groups" section)
     * @return boolean
     */
    public static function isGroupCustomUseNamePrefixEnabled() {
        $appConfig = \OC::$server->getAppConfig();
        $result = $appConfig->getValue('group_custom', 'group_custom_use_name_prefix_enabled', 'no');
        return ($result === 'yes') ? true : false;
    }

    /**
     * Get the prefix set for custom group name
     * @return string
     */
    public static function getGroupCustomNamePrefix() {
        $result = '';

        if (self::isGroupCustomUseNamePrefixEnabled()) {
            $appConfig = \OC::$server->getAppConfig();
            $result = $appConfig->getValue('group_custom', 'group_custom_name_prefix', 'GC_');

        }

        return $result;
    }

    /**
     * Set the prefix for custom group name
     * @param string $prefix
     */
    public static function setGroupCustomNamePrefix($prefix='') {
        if (self::isGroupCustomUseNamePrefixEnabled()) {
            $appConfig = \OC::$server->getAppConfig();
            $appConfig->setValue('group_custom', 'group_custom_name_prefix', $prefix);
        }
    }

    /**
     *
     */
    public static function isPrefixValid($prefix) {
        $validRegexp = "/^[a-zA-Z0-9-_:@$\/]*$/";
        return preg_match($validRegexp, $prefix);
    }

    /**
     * Add the prefix to the group name
     * @param string $gid Group name
     * @return string The prefixed grouped name, if prefix is enabled
     */
    public static function normalizeGroupName($gid) {
        $prefix = self::getGroupCustomNamePrefix();

        return $prefix . $gid;
    }
}<commit_msg>Don't had prefix if groupname is already prefixed.<commit_after><?php

namespace OCA\Group_Custom;

class Helper {
    /**
     * Verify if prefix is enabled (see general settings screen, "Custom Groups" section)
     * @return boolean
     */
    public static function isGroupCustomUseNamePrefixEnabled() {
        $appConfig = \OC::$server->getAppConfig();
        $result = $appConfig->getValue('group_custom', 'group_custom_use_name_prefix_enabled', 'no');
        return ($result === 'yes') ? true : false;
    }

    /**
     * Get the prefix set for custom group name
     * @return string
     */
    public static function getGroupCustomNamePrefix() {
        $result = '';

        if (self::isGroupCustomUseNamePrefixEnabled()) {
            $appConfig = \OC::$server->getAppConfig();
            $result = $appConfig->getValue('group_custom', 'group_custom_name_prefix', 'GC_');

        }

        return $result;
    }

    /**
     * Set the prefix for custom group name
     * @param string $prefix
     */
    public static function setGroupCustomNamePrefix($prefix='') {
        if (self::isGroupCustomUseNamePrefixEnabled()) {
            $appConfig = \OC::$server->getAppConfig();
            $appConfig->setValue('group_custom', 'group_custom_name_prefix', $prefix);
        }
    }

    /**
     *
     */
    public static function isPrefixValid($prefix) {
        $validRegexp = "/^[a-zA-Z0-9-_:@$\/]*$/";
        return preg_match($validRegexp, $prefix);
    }

    /**
     * Add the prefix to the group name
     * @param string $gid Group name
     * @return string The prefixed grouped name, if prefix is enabled
     */
    public static function normalizeGroupName($gid) {
        $prefix = self::getGroupCustomNamePrefix();
        // if group name is already prefixed, don't add prefix again
        if (strpos($gid, $prefix) === 0) {
            return $gid;
        }

        return $prefix . $gid;
    }
}

{'fraction_non_alphanumeric': 0.1312449365379422, 'fraction_numerical': 0.0013502565487442614, 'mean_word_length': 2.507575757575758, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1014261', 'n_tokens_mistral': 1068, 'n_tokens_neox': 1037, 'n_words': 263}