/**
  * The summary of all settings available. The menu items displayed here are
  * collected from each application's application controller and all plugin's
  * definitions.
  */
 public function Index()
 {
     $this->ApplicationFolder = 'dashboard';
     $this->MasterView = 'setup';
     // Fatal error if Garden has already been installed.
     $Installed = Gdn::Config('Garden.Installed') ? TRUE : FALSE;
     if ($Installed) {
         throw new Exception('Vanilla has already been installed.');
     }
     if (!$this->_CheckPrerequisites()) {
         $this->View = 'prerequisites';
     } else {
         $this->View = 'configure';
         // Make sure the user has copied the htaccess file over.
         if (!file_exists(PATH_ROOT . '/.htaccess') && !$this->Form->GetFormValue('SkipHtaccess')) {
             $this->SetData('NoHtaccess', TRUE);
             $this->Form->AddError(T('You are missing Vanilla\'s .htaccess file.', 'You are missing Vanilla\'s <b>.htaccess</b> file. Sometimes this file isn\'t copied if you are using ftp to upload your files because this file is hidden. Make sure you\'ve copied the <b>.htaccess</b> file before continuing.'));
         }
         $ApplicationManager = new Gdn_ApplicationManager();
         $AvailableApplications = $ApplicationManager->AvailableApplications();
         // Need to go through all of the setups for each application. Garden,
         if ($this->Configure() && $this->Form->IsPostBack()) {
             // Step through the available applications, enabling each of them
             $AppNames = array_keys($AvailableApplications);
             try {
                 foreach ($AvailableApplications as $AppName => $AppInfo) {
                     if (strtolower($AppName) != 'dashboard') {
                         $Validation = new Gdn_Validation();
                         $ApplicationManager->RegisterPermissions($AppName, $Validation);
                         $ApplicationManager->EnableApplication($AppName, $Validation);
                     }
                 }
             } catch (Exception $ex) {
                 $this->Form->AddError($ex);
             }
             if ($this->Form->ErrorCount() == 0) {
                 // Save a variable so that the application knows it has been installed.
                 // Now that the application is installed, select a more user friendly error page.
                 $Config = array('Garden.Installed' => TRUE);
                 if (!defined('DEBUG')) {
                     $Config['Garden.Errors.MasterView'] = 'error.master.php';
                 }
                 SaveToConfig($Config);
                 // Go to the dashboard
                 Redirect('/settings');
             }
         }
     }
     $this->Render();
 }
 /**
  * The summary of all settings available. The menu items displayed here are
  * collected from each application's application controller and all plugin's
  * definitions.
  */
 public function Index()
 {
     $this->ApplicationFolder = 'dashboard';
     $this->MasterView = 'setup';
     // Fatal error if Garden has already been installed.
     $Config = Gdn::Factory(Gdn::AliasConfig);
     $Installed = Gdn::Config('Garden.Installed') ? TRUE : FALSE;
     if ($Installed) {
         throw new Exception('Vanilla has already been installed.');
     }
     if (!$this->_CheckPrerequisites()) {
         $this->View = 'prerequisites';
     } else {
         $this->View = 'configure';
         $ApplicationManager = new Gdn_ApplicationManager();
         $AvailableApplications = $ApplicationManager->AvailableApplications();
         // Need to go through all of the setups for each application. Garden,
         if ($this->Configure() && $this->Form->IsPostBack()) {
             // Step through the available applications, enabling each of them
             $AppNames = array_keys($AvailableApplications);
             try {
                 foreach ($AvailableApplications as $AppName => $AppInfo) {
                     if (strtolower($AppName) != 'dashboard') {
                         $Validation = new Gdn_Validation();
                         $ApplicationManager->RegisterPermissions($AppName, $Validation);
                         $ApplicationManager->EnableApplication($AppName, $Validation);
                     }
                 }
             } catch (Exception $ex) {
                 $this->Form->AddError($ex);
             }
             if ($this->Form->ErrorCount() == 0) {
                 // Save a variable so that the application knows it has been installed.
                 // Now that the application is installed, select a more user friendly error page.
                 $Config = array('Garden.Installed' => TRUE);
                 if (!defined('DEBUG')) {
                     $Config['Garden.Errors.MasterView'] = 'error.master.php';
                 }
                 SaveToConfig($Config);
                 // Go to the dashboard
                 Redirect('/settings');
             }
         }
     }
     $this->Render();
 }
 /**
  *
  *
  * @param bool $Enabled
  * @return array
  */
 public function getAddons($Enabled = false)
 {
     $Addons = array();
     // Get the core.
     self::_AddAddon(array('AddonKey' => 'vanilla', 'AddonType' => 'core', 'Version' => APPLICATION_VERSION, 'Folder' => '/'), $Addons);
     // Get a list of all of the applications.
     $ApplicationManager = new Gdn_ApplicationManager();
     if ($Enabled) {
         $Applications = $ApplicationManager->AvailableApplications();
     } else {
         $Applications = $ApplicationManager->EnabledApplications();
     }
     foreach ($Applications as $Key => $Info) {
         // Exclude core applications.
         if (in_array(strtolower($Key), array('conversations', 'dashboard', 'skeleton', 'vanilla'))) {
             continue;
         }
         $Addon = array('AddonKey' => $Key, 'AddonType' => 'application', 'Version' => val('Version', $Info, '0.0'), 'Folder' => '/applications/' . GetValue('Folder', $Info, strtolower($Key)));
         self::_AddAddon($Addon, $Addons);
     }
     // Get a list of all of the plugins.
     $PluginManager = Gdn::pluginManager();
     if ($Enabled) {
         $Plugins = $PluginManager->EnabledPlugins();
     } else {
         $Plugins = $PluginManager->AvailablePlugins();
     }
     foreach ($Plugins as $Key => $Info) {
         // Exclude core plugins.
         if (in_array(strtolower($Key), array())) {
             continue;
         }
         $Addon = array('AddonKey' => $Key, 'AddonType' => 'plugin', 'Version' => val('Version', $Info, '0.0'), 'Folder' => '/applications/' . GetValue('Folder', $Info, $Key));
         self::_AddAddon($Addon, $Addons);
     }
     // Get a list of all the themes.
     $ThemeManager = new Gdn_ThemeManager();
     if ($Enabled) {
         $Themes = $ThemeManager->EnabledThemeInfo(true);
     } else {
         $Themes = $ThemeManager->AvailableThemes();
     }
     foreach ($Themes as $Key => $Info) {
         // Exclude core themes.
         if (in_array(strtolower($Key), array('default'))) {
             continue;
         }
         $Addon = array('AddonKey' => $Key, 'AddonType' => 'theme', 'Version' => val('Version', $Info, '0.0'), 'Folder' => '/themes/' . GetValue('Folder', $Info, $Key));
         self::_AddAddon($Addon, $Addons);
     }
     // Get a list of all locales.
     $LocaleModel = new LocaleModel();
     if ($Enabled) {
         $Locales = $LocaleModel->EnabledLocalePacks(true);
     } else {
         $Locales = $LocaleModel->AvailableLocalePacks();
     }
     foreach ($Locales as $Key => $Info) {
         // Exclude core themes.
         if (in_array(strtolower($Key), array('skeleton'))) {
             continue;
         }
         $Addon = array('AddonKey' => $Key, 'AddonType' => 'locale', 'Version' => val('Version', $Info, '0.0'), 'Folder' => '/locales/' . GetValue('Folder', $Info, $Key));
         self::_AddAddon($Addon, $Addons);
     }
     return $Addons;
 }
Exemple #4
0
 /**
  * Application management screen.
  */
 public function Applications($Action = '', $ApplicationName = '', $TransientKey = '')
 {
     $this->Permission('Garden.Applications.Manage');
     $this->AddSideMenu('garden/settings/applications');
     if ($this->Head) {
         $this->Head->AddScript('/applications/garden/js/applications.js');
     }
     $Session = Gdn::Session();
     $AuthenticatedPostBack = $this->Form->AuthenticatedPostBack();
     // Todd: Is this part necessary?
     if (!$Session->ValidateTransientKey($TransientKey)) {
         // if(!$AuthenticatedPostBack) {
         $Action = '';
         $ApplicationName = '';
     } else {
         $AuthenticatedPostBack = TRUE;
     }
     $FinalRedirect = FALSE;
     $SetupRender = FALSE;
     $ApplicationManager = new Gdn_ApplicationManager();
     $this->AvailableApplications = $ApplicationManager->AvailableApplications();
     // Check the update server for updates to these applications
     $this->UpdateManager = new Gdn_UpdateManager();
     // TODO: FIX UP THE PHONE-HOME CODE - AJAX, PERHAPS?
     // $this->CurrentVersions = $this->UpdateManager->Check(ADDON_TYPE_APPLICATION, array_keys($this->AvailableApplications));
     if ($AuthenticatedPostBack) {
         $ApplicationName = $this->Form->GetValue('ApplicationName', $ApplicationName);
         if ($ApplicationName != '') {
             if (array_key_exists($ApplicationName, $this->EnabledApplications) === TRUE) {
                 try {
                     $ApplicationManager->DisableApplication($ApplicationName);
                 } catch (Exception $e) {
                     $this->Form->AddError(strip_tags($e->getMessage()));
                 }
                 $FinalRedirect = TRUE;
             } else {
                 if ($Action == '') {
                     // 1. Make sure that the application's requirements are met
                     try {
                         $ApplicationManager->CheckRequirements($ApplicationName);
                     } catch (Exception $e) {
                         $this->Form->AddError(strip_tags($e->getMessage()));
                     }
                     if ($this->Form->ErrorCount() == 0) {
                         // 2. Register any specified permissions
                         $Validation = new Gdn_Validation();
                         $ApplicationManager->RegisterPermissions($ApplicationName, $Validation);
                         if (count($Validation->Results()) == 0) {
                             if (!$ApplicationManager->ApplicationSetup($ApplicationName, $this, $Validation, TRUE)) {
                                 $SetupUrl = '/garden/settings/applications/setup/' . $ApplicationName . '/' . $Session->TransientKey();
                                 if ($this->_DeliveryType === DELIVERY_TYPE_ALL) {
                                     Redirect($SetupUrl);
                                 } else {
                                     $this->SetJson('Go', Url($SetupUrl));
                                     // <---- THIS IS WHAT MAKES IT GET PICKED UP BY THE POPUP
                                     $this->Database->CloseConnection();
                                     exit(json_encode($this->GetJson()));
                                 }
                             } else {
                                 $FinalRedirect = TRUE;
                             }
                         }
                     }
                     $this->Form->SetValidationResults($Validation->Results());
                 } elseif ($Action == 'setup') {
                     // 3. Run the setup method of the application
                     $SetupRender = TRUE;
                     $Validation = new Gdn_Validation();
                     if ($ApplicationManager->ApplicationSetup($ApplicationName, $this, $Validation)) {
                         $SetupRender = FALSE;
                         $FinalRedirect = TRUE;
                     }
                 }
             }
             if ($FinalRedirect && $this->Form->ErrorCount() == 0) {
                 $this->StatusMessage = Gdn::Translate('Finalizing changes...');
                 $this->RedirectUrl = Url('/garden/settings/applications/');
             }
         }
     }
     if (!$SetupRender) {
         $this->Render();
     }
 }