private function init() { $url = parse_url($r = waRequest::server('HTTP_REFERER'), PHP_URL_QUERY); if (preg_match('/(^|&)module=(update|apps|plugins)($|&)/', $url, $matches)) { $this->module = $matches[2]; } if (installerHelper::isDeveloper()) { if (waRequest::request('install')) { $msg = _w('Unable to install application (developer version is on)'); } else { $msg = _w('Unable to install application (developer version is on)'); } $this->redirect(array('module' => $this->module, 'msg' => installerMessage::getInstance()->raiseMessage($msg, 'fail'))); } }
public function execute() { //TODO use POST $app_ids = waRequest::request('app_id'); try { if (installerHelper::isDeveloper()) { throw new waException(_w('Unable to delete application (developer version is on)')); } if (!$app_ids || !is_array($app_ids)) { throw new waException(_w('Application not found')); } foreach ($app_ids as &$info) { if (!is_array($info)) { $info = array('vendor' => $info); } } unset($info); $this->apps = new waInstallerApps(); $app_list = $this->apps->getApps(array('installed' => true)); $deleted_apps = array(); foreach ($app_list as $info) { $app_id = $info['slug']; if (isset($app_ids[$app_id]) && $app_ids[$app_id]['vendor'] == $info['vendor']) { if (!empty($info['installed']['system'])) { throw new waException(sprintf(_w('Can not delete system application "%s"'), $info['name'])); } $deleted_apps[] = $this->deleteApp($app_id); } } wa()->setActive('installer'); if (!$deleted_apps) { throw new waException(_w('Application not found')); } $message = _w('Application %s has been deleted', 'Applications %s have been deleted', min(2, count($deleted_apps)), false); $message = sprintf($message, implode(', ', $deleted_apps)); $msg = installerMessage::getInstance()->raiseMessage($message); } catch (Exception $ex) { wa()->setActive('installer'); $msg = installerMessage::getInstance()->raiseMessage($ex->getMessage(), installerMessage::R_FAIL); } //'module' => installerHelper::getModule(), $this->redirect(array('msg' => $msg)); }
private function init() { $url = parse_url($r = waRequest::server('HTTP_REFERER'), PHP_URL_QUERY); if (preg_match('/(^|&)module=(themes|plugins)($|&)/', $url, $matches)) { $this->extras_type = $matches[2]; } elseif (preg_match('/^installer(\\w+)RemoveAction$/', get_class($this), $matches)) { $this->extras_type = strtolower($matches[1]); } if (installerHelper::isDeveloper()) { switch ($this->extras_type) { case 'themes': $msg = _w("Unable to delete application's themes (developer version is on)"); break; case 'plugins': $msg = _w("Unable to delete application's plugins (developer version is on)"); break; default: $msg = '???'; break; } $msg = installerMessage::getInstance()->raiseMessage($msg, installerMessage::R_FAIL); $this->redirect('?msg=' . $msg . '#/' . $this->extras_type . '/'); } }
function execute() { $module = 'apps'; $url = parse_url(waRequest::server('HTTP_REFERER'), PHP_URL_QUERY); if (preg_match('/(^|&)module=(update|apps|plugins)($|&)/', $url, $matches)) { $module = $matches[2]; } $app_ids = waRequest::get('app_id'); try { if (!$app_ids || !is_array($app_ids)) { throw new waException(_w('Application not found')); } $vendors = array(); foreach ($app_ids as $app_id => &$info) { if (!is_array($info)) { $info = array('vendor' => $info); } $vendors[] = $info['vendor']; unset($info); } $vendors = array_unique($vendors); $apps = new waInstallerApps(); $app_list = $apps->getApplicationsList(true, $vendors); $deleted_apps = array(); if (installerHelper::isDeveloper()) { throw new waException(_w('Unable to delete application (developer version is on)')); } foreach ($app_list as $info) { $app_id = $info['slug']; if (isset($app_ids[$app_id]) && $app_ids[$app_id]['vendor'] == $info['vendor']) { if (isset($info['system']) && $info['system']) { throw new waException(sprintf(_w('Can not delete system application "%s"'), $info['name'])); } $apps->updateRoutingConfig($app_id, false); $apps->updateAppConfig($app_id, null); //remove db tables and etc $paths = array(); $app_instance = waSystem::getInstance($app_id); $plugins = $app_instance->getConfig()->getPlugins(); foreach ($plugins as $plugin_id => $plugin) { if ($plugin && ($plugin_instance = $app_instance->getPlugin($plugin_id))) { $plugin_instance->uninstall(); } $apps->updateAppPluginsConfig($app_id, $plugin_id, null); //wa-apps/$app_id/plugins/$slug $paths[] = wa()->getAppPath("plugins/{$plugin_id}", $app_id); foreach ($paths as $path) { waFiles::delete($path, true); } $paths = array(); } $app_instance->getConfig()->uninstall(); //XXX called at uninstall //$paths[] = wa()->getAppCachePath(null, $app_id);//wa-cache/apps/$app_id/ $paths[] = wa()->getTempPath(null, $app_id); //wa-cache/temp/$app_id/ $paths[] = wa()->getAppCachePath(null, $app_id); //wa-cache/apps/$app_id/ $paths[] = wa()->getDataPath(null, true, $app_id); //wa-data/public/$app_id/ $paths[] = wa()->getDataPath(null, false, $app_id); //wa-data/protected/$app_id/ //XXX uncomplete code //$paths[] = wa()-> null, false, $app_id);//wa-log/$app_id/ //XXX uncomplete code //$paths[] = wa()->getAppPath(null, $app_id);//wa-config/$app_id/ $paths[] = wa()->getAppPath(null, $app_id); //wa-apps/$app_id/ foreach ($paths as $path) { waFiles::delete($path, true); } $deleted_apps[] = $info['name']; } } if (!$deleted_apps) { throw new waException(_w('Application not found')); } $message = _w('Application %s has been deleted', 'Applications %s have been deleted', min(2, count($deleted_apps)), false); $message = sprintf($message, implode(', ', $deleted_apps)); $msg = installerMessage::getInstance()->raiseMessage($message); $this->redirect(array('module' => $module, 'msg' => $msg)); } catch (Exception $ex) { $msg = installerMessage::getInstance()->raiseMessage($ex->getMessage(), installerMessage::R_FAIL); $this->redirect(array('module' => $module, 'msg' => $msg)); } }
function execute() { if (!$this->extras_type && preg_match('/^installer(\\w+)RemoveAction$/', get_class($this), $matches)) { $this->extras_type = strtolower($matches[1]); } $module = $this->extras_type; $url = parse_url(waRequest::server('HTTP_REFERER'), PHP_URL_QUERY); if (preg_match("/(^|&)module=(update|apps| {\n {$this->extras_type}})(\$|&)/", $url, $matches)) { $module = $matches[2]; } $extras_ids = waRequest::get('extras_id'); try { /* _w('Application themes not found'); _w('Application plugins not found'); */ //$message = sprintf('Application %s not found', $this->extras_type); //throw new waException(_w($message)); if (installerHelper::isDeveloper()) { /* _w("Unable to delete application's themes (developer version is on)"); _w("Unable to delete application's plugins (developer version is on)"); */ $message = "Unable to delete application's {$this->extras_type} (developer version is on)"; throw new waException(_w($message)); } $vendors = array(); foreach ($extras_ids as $extras_id => &$info) { if (!is_array($info)) { $info = array('vendor' => $info); } $vendors[] = $info['vendor']; unset($info); } $vendors = array_unique($vendors); $locale = wa()->getLocale(); $this->installer = new waInstallerApps(null, $locale); $app_list = $this->installer->getApplicationsList(true); $deleted_extras = array(); foreach ($app_list as $app) { if (isset($app['extras']) && $app['extras'] && isset($app['extras'][$this->extras_type]) && $app['extras'][$this->extras_type]) { foreach ($app['extras'][$this->extras_type] as $extras_id => $info) { $slug = $info['slug']; if (isset($extras_ids[$slug]) && $extras_ids[$slug]['vendor'] == $info['current']['vendor']) { if (isset($info['system']) && $info['system']) { /* _w("Can not delete system application's themes \"%s\""); _w("Can not delete system application's plugins \"%s\""); */ $message = "Can not delete system application's {$this->extras_type} \"%s\""; throw new waException(sprintf(_w($message), $info['name'])); } if ($this->removeExtras($app['slug'], $extras_id, $info)) { $deleted_extras[] = "{$info['name']} ({$app['name']})"; } unset($extras_ids[$slug]); } } } } foreach ($extras_ids as $slug => $data) { if (preg_match('@^wa-plugins/([^/]+/[^/]+)$@', $slug, $matches)) { $path = wa()->getConfig()->getPath('plugins') . '/' . $matches[1]; $info_path = $path . '/lib/config/plugin.php'; if (file_exists($info_path) && ($info = (include $info_path))) { waFiles::delete($path, true); $deleted_extras[] = empty($info['name']) ? $matches[1] : $info['name']; } } } if (!$deleted_extras) { $message = sprintf('Application %s not found', $this->extras_type); throw new waException(_w($message)); } /* _w('Application plugin %s has been deleted', 'Applications plugins %s have been deleted'); _w('Application theme %s has been deleted', 'Applications themes %s have been deleted'); */ $message_singular = sprintf('Application %s %%s has been deleted', preg_replace('/s$/', '', $this->extras_type)); $message_plural = sprintf('Applications %a %%s have been deleted', $this->extras_type); $message = sprintf(_w($message_singular, $message_plural, count($deleted_extras), false), implode(', ', $deleted_extras)); $msg = installerMessage::getInstance()->raiseMessage($message); $this->redirect(array('module' => $module, 'msg' => $msg)); } catch (Exception $ex) { $msg = installerMessage::getInstance()->raiseMessage($ex->getMessage(), installerMessage::R_FAIL); $this->redirect(array('module' => $module, 'msg' => $msg)); } }