protected function validateLimitsUpload()
    {
        $files = $this->request->file('files');

        if (!gplcart_file_multi_upload($files)) {
            return false;
        }

        if ($this->user->isSuperadmin()) {
            return true;
        }

        $role_id = $this->user->getRoleId();
        $settings = $this->module->getSettings('file_manager');

        $maxfilesize = 0;
        $extensions = array();

        if (!empty($settings['filesize_limit'][$role_id])) {
            $maxfilesize = $settings['filesize_limit'][$role_id];
        }

        if (!empty($settings['extension_limit'][$role_id])) {
            $extensions = $settings['extension_limit'][$role_id];
        }

        $errors = array();
        foreach ($files as $file) {

            if ($maxfilesize && filesize($file['tmp_name']) > $maxfilesize) {
                unlink($file['tmp_name']);
                $errors[] = "{$file['name']}: " . $this->translation->text('File size exceeds %num bytes', array('%num' => $maxfilesize));
                continue;
            }

            if ($extensions && !in_array(pathinfo($file['name'], PATHINFO_EXTENSION), $extensions)) {
                unlink($file['tmp_name']);
                $errors[] = "{$file['name']}: " . $this->translation->text('Unsupported file extension');
            }
        }

        if (empty($errors)) {
            return true;
        }

        $this->setError('files', implode('<br>', $errors));
        return false;
    }