Esempio n. 1
0
        private IEnumerable <UpdatePackageEntry> GetPackagesWorker(PackagingSource packagingSource)
        {
            var list = new Dictionary <string, UpdatePackageEntry>(StringComparer.OrdinalIgnoreCase);

            var extensions = _extensionManager.AvailableExtensions();

            foreach (var extension in extensions)
            {
                var packageId = PackageBuilder.BuildPackageId(extension.Id, extension.ExtensionType);

                GetOrAddEntry(list, packageId).ExtensionsDescriptor = extension;
            }

            var packages = _packagingSourceManager.GetExtensionList(false, packagingSource)
                           .ToList()
                           .GroupBy(p => p.PackageId, StringComparer.OrdinalIgnoreCase);

            foreach (var package in packages)
            {
                var entry = GetOrAddEntry(list, package.Key);
                entry.PackageVersions = entry.PackageVersions.Concat(package).ToList();
            }

            return(list.Values.Where(e => e.ExtensionsDescriptor != null && e.PackageVersions.Any()));
        }
        public void Uninstall(string packageId, string applicationPath)
        {
            var extensionToUninstall = _extensionManager.AvailableExtensions()
                                       .FirstOrDefault(extension => PackageBuilder.BuildPackageId(extension.Id, extension.ExtensionType) == packageId);

            if (extensionToUninstall == null)
            {
                throw new OrchardException(T("There is no extension that has the package ID \"{0}\".", packageId));
            }

            var featureIdsToUninstall = extensionToUninstall.Features.Select(feature => feature.Id);
            var shellState            = _shellStateManager.GetShellState();
            var featureStates         = shellState.Features.Where(featureState => featureIdsToUninstall.Contains(featureState.Name));

            // This means that no feature from this extension wasn enabled yet, can be uninstalled directly.
            if (!featureStates.Any())
            {
                _packageUninstallHandler.QueuePackageUninstall(packageId);
            }
            else
            {
                _featureManager.DisableFeatures(extensionToUninstall.Features.Select(feature => feature.Id), true);

                // Installed state can't be deduced from the shell state changes like for enabled state, so have to
                // set that explicitly.
                foreach (var featureState in featureStates)
                {
                    _shellStateManager.UpdateInstalledState(featureState, Environment.State.Models.ShellFeatureState.State.Falling);
                }
            }
        }
Esempio n. 3
0
        public ActionResult RemoveThemePOST(string themeId, string returnUrl, string retryUrl)
        {
            if (_shellSettings.Name != ShellSettings.DefaultName || !Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to remove themes")))
            {
                return(new HttpUnauthorizedResult());
            }

            return(UninstallPackage(PackageBuilder.BuildPackageId(themeId, DefaultExtensionTypes.Theme), returnUrl, retryUrl));
        }
Esempio n. 4
0
        public override IQueryable <IPackage> GetPackages()
        {
            IEnumerable <IPackage> repositoryPackages = SourceRepository.GetPackages().ToList();
            IEnumerable <IPackage> packages           = from extension in _extensionManager.AvailableExtensions()
                                                        let id = PackageBuilder.BuildPackageId(extension.Id, extension.ExtensionType)
                                                                 let version = extension.Version != null?Version.Parse(extension.Version) : null
                                                                                   let package = repositoryPackages.FirstOrDefault(p => p.Id == id && (version == null || p.Version == version))
                                                                                                     where package != null
                                                                                                 select package;

            return(packages.AsQueryable());
        }
Esempio n. 5
0
        public ActionResult UninstallThemePost(string themeId, string returnUrl, string retryUrl)
        {
            if (String.IsNullOrEmpty(themeId))
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            if (_shellSettings.Name != ShellSettings.DefaultName || !Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to remove themes")))
            {
                return(new HttpUnauthorizedResult());
            }

            return(UninstallPackage(PackageBuilder.BuildPackageId(themeId, DefaultExtensionTypes.Theme), returnUrl, retryUrl));
        }
 public void Uninstalled(Feature feature)
 {
     QueuePackageUninstall(PackageBuilder.BuildPackageId(feature.Descriptor.Extension.Id, feature.Descriptor.Extension.ExtensionType));
 }