public function installAction() { $this->view->form = $form = new Install_Form_Confirm(array('title' => 'Install Package?', 'description' => 'Are you sure you want to install this package?', 'submitLabel' => 'Install Package', 'cancelHref' => $this->view->url(array('action' => 'index')), 'useToken' => true)); if (!$this->getRequest()->isPost()) { return; } if (!$form->isValid($this->getRequest()->getPost())) { return; } // Do the disable $packageName = $this->_getParam('package'); $package = null; foreach ($this->_packageManager->listInstalledPackages() as $installedPackage) { if ($installedPackage->getKey() == $packageName) { $package = $installedPackage; } } // Enable/disable $operation = new Engine_Package_Manager_Operation_Install($this->_packageManager, $package); $errors = array(); $queryError = false; // Run preinstall $result = $this->_packageManager->execute($operation, 'preinstall'); if (!empty($result['errors'])) { $queryError = true; $errors = array_merge($errors, $result['errors']); } if (isset($queryError) && $queryError) { $this->view->queryError = true; $this->view->errors = $errors; return; } // Run install $result = $this->_packageManager->execute($operation, 'install'); if (!empty($result['errors'])) { $queryError = true; $errors = array_merge($errors, $result['errors']); } if (isset($queryError) && $queryError) { $this->view->queryError = true; $this->view->errors = $errors; return; } // Run postinstall $result = $this->_packageManager->execute($operation, 'postinstall'); if (!empty($result['errors'])) { $queryError = true; $errors = array_merge($errors, $result['errors']); } if (isset($queryError) && $queryError) { $this->view->queryError = true; $this->view->errors = $errors; return; } // Redirect if no error if (!isset($queryError) || !$queryError) { return $this->_helper->redirector->gotoRoute(array('action' => 'index')); } }
public function deleteAction() { $this->view->form = $form = new Install_Form_Confirm(array('action' => $_SERVER['REQUEST_URI'], 'title' => 'Delete Packages?', 'description' => 'Are you sure you want to delete these packages?', 'submitLabel' => 'Delete Packages', 'cancelHref' => $this->view->url(array('action' => 'manage')), 'useToken' => true)); if (!$this->getRequest()->isPost()) { return; } if (!$form->isValid($this->getRequest()->getPost())) { return; } $actions = (array) $this->_getParam('actions'); foreach ($actions as $action) { $path = $this->_outputPath . '/' . $action; if (file_exists($path) && is_file($path)) { @unlink($path); } } return $this->_helper->redirector->gotoRoute(array('action' => 'manage')); }