本文整理汇总了PHP中Plugins::deactivate方法的典型用法代码示例。如果您正苦于以下问题:PHP Plugins::deactivate方法的具体用法?PHP Plugins::deactivate怎么用?PHP Plugins::deactivate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plugins
的用法示例。
在下文中一共展示了Plugins::deactivate方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mdh_emailmagick_bump_me
/**
* Makes this plugin the first to be loaded.
* - Bumps this plugin at the top of the active_plugins stack.
*/
function mdh_emailmagick_bump_me()
{
if (OC_ADMIN) {
// @legacy : ALWAYS remove this if active.
if (osc_plugin_is_enabled("madhouse_utils/index.php")) {
Plugins::deactivate("madhouse_utils/index.php");
}
// Sanitize & get the {PLUGIN_NAME}/index.php.
$path = str_replace(osc_plugins_path(), '', osc_plugin_path(__FILE__));
if (osc_plugin_is_installed($path)) {
// Get the active plugins.
$plugins_list = unserialize(osc_active_plugins());
if (!is_array($plugins_list)) {
return false;
}
// Remove $path from the active plugins list
foreach ($plugins_list as $k => $v) {
if ($v == $path) {
unset($plugins_list[$k]);
}
}
// Re-add the $path at the beginning of the active plugins.
array_unshift($plugins_list, $path);
// Serialize the new active_plugins list.
osc_set_preference('active_plugins', serialize($plugins_list));
if (Params::getParam("page") === "plugins" && Params::getParam("action") === "enable" && Params::getParam("plugin") === $path) {
//osc_redirect_to(osc_admin_base_url(true) . "?page=plugins");
} else {
osc_redirect_to(osc_admin_base_url(true) . "?" . http_build_query(Params::getParamsAsArray("get")));
}
}
}
}
示例2: errorHandler
function errorHandler($pn)
{
if (false === is_null($aError = error_get_last())) {
Plugins::deactivate($pn);
osc_add_flash_error_message(sprintf(_m('There was a fatal error and the plugin was not installed.<br />Error: "%s" Line: %s<br/>File: %s'), $aError['message'], $aError['line'], $aError['file']), 'admin');
$this->redirectTo(osc_admin_base_url(true) . "?page=plugins");
}
}
示例3: doModel
function doModel()
{
parent::doModel();
//specific things for this class
switch ($this->action) {
case 'add':
$this->doView("plugins/add.php");
break;
case 'add_post':
$package = Params::getFiles("package");
$path = osc_plugins_path();
(int) ($status = osc_unzip_file($package['tmp_name'], $path));
switch ($status) {
case 0:
$msg = _m('The plugin folder is not writable');
break;
case 1:
$msg = _m('The plugin has been uploaded correctly');
break;
case 2:
$msg = _m('The zip file is not valid');
break;
case -1:
default:
$msg = _m('There was a problem adding the plugin');
break;
}
osc_add_flash_message($msg, 'admin');
$this->redirectTo(osc_admin_base_url(true) . "?page=plugins");
break;
case 'install':
$pn = Params::getParam("plugin");
Plugins::activate($pn);
//run this after installing the plugin
Plugins::runHook('install_' . $pn);
osc_add_flash_message(_m('Plugin installed'), 'admin');
$this->redirectTo(osc_admin_base_url(true) . "?page=plugins");
break;
case 'uninstall':
$pn = Params::getParam("plugin");
Plugins::runHook($pn . '_uninstall');
Plugins::deactivate($pn);
osc_add_flash_message(_m('Plugin uninstalled'), 'admin');
$this->redirectTo(osc_admin_base_url(true) . "?page=plugins");
break;
case 'admin':
global $active_plugins;
$plugin = Params::getParam("plugin");
if ($plugin != "") {
Plugins::runHook($plugin . '_configure');
}
break;
case 'admin_post':
Plugins::runHook('admin_post');
case 'renderplugin':
global $active_plugins;
$file = Params::getParam("file");
if ($file != "") {
// We pass the GET variables (in case we have somes)
if (preg_match('|(.+?)\\?(.*)|', $file, $match)) {
$file = $match[1];
if (preg_match_all('|&([^=]+)=([^&]*)|', urldecode('&' . $match[2] . '&'), $get_vars)) {
for ($var_k = 0; $var_k < count($get_vars[1]); $var_k++) {
//$_GET[$get_vars[1][$var_k]] = $get_vars[2][$var_k];
//$_REQUEST[$get_vars[1][$var_k]] = $get_vars[2][$var_k];
Params::setParam($get_vars[1][$var_k], $get_vars[2][$var_k]);
}
}
} else {
$file = $_REQUEST['file'];
}
$this->_exportVariableToView("file", osc_plugins_path() . $file);
//osc_renderPluginView($file);
$this->doView("plugins/view.php");
}
break;
case 'configure':
$plugin = Params::getParam("plugin");
if ($plugin != '') {
$plugin_data = Plugins::getInfo($plugin);
$this->_exportVariableToView("categories", Category::newInstance()->toTreeAll());
$this->_exportVariableToView("selected", PluginCategory::newInstance()->listSelected($plugin_data['short_name']));
$this->_exportVariableToView("plugin_data", $plugin_data);
$this->doView("plugins/configuration.php");
} else {
$this->redirectTo(osc_admin_base_url(true) . "?page=plugins");
}
break;
case 'configure_post':
$plugin_short_name = Params::getParam("plugin_short_name");
$categories = Params::getParam("categories");
if ($plugin_short_name != "") {
Plugins::cleanCategoryFromPlugin($plugin_short_name);
if (isset($categories)) {
Plugins::addToCategoryPlugin($categories, $plugin_short_name);
}
} else {
osc_add_flash_message(_m('No plugin selected'), 'admin');
$this->doView("plugins/index.php");
}
//.........这里部分代码省略.........
示例4: doModel
//.........这里部分代码省略.........
/************************
*** CHECK VALID CODE ***
************************/
if ($code != '' && $section != '') {
if (stripos($code, "http://") === FALSE) {
// OSCLASS OFFICIAL REPOSITORY
$url = osc_market_url($section, $code);
$data = json_decode(osc_file_get_contents($url), true);
} else {
// THIRD PARTY REPOSITORY
if (osc_market_external_sources()) {
$data = json_decode(osc_file_get_contents($code), true);
} else {
echo json_encode(array('error' => 8, 'error_msg' => __('No external sources are allowed')));
break;
}
}
/***********************
**** DOWNLOAD FILE ****
***********************/
if (isset($data['s_update_url']) && isset($data['s_source_file']) && isset($data['e_type'])) {
if ($data['e_type'] == 'THEME') {
$folder = 'themes/';
} else {
if ($data['e_type'] == 'LANGUAGE') {
$folder = 'languages/';
} else {
// PLUGINS
$folder = 'plugins/';
$plugin = Plugins::findByUpdateURI($data['s_update_url']);
if ($plugin != false) {
if (Plugins::isEnabled($plugin)) {
Plugins::runHook($plugin . '_disable');
Plugins::deactivate($plugin);
$re_enable = true;
}
}
}
}
$filename = $data['s_update_url'] . "_" . $data['s_version'] . ".zip";
$url_source_file = $data['s_source_file'];
// error_log('Source file: ' . $url_source_file);
// error_log('Filename: ' . $filename);
$result = osc_downloadFile($url_source_file, $filename);
if ($result) {
// Everything is OK, continue
/**********************
***** UNZIP FILE *****
**********************/
@mkdir(ABS_PATH . 'oc-temp', 0777);
$res = osc_unzip_file(osc_content_path() . 'downloads/' . $filename, osc_content_path() . 'downloads/oc-temp/');
if ($res == 1) {
// Everything is OK, continue
/**********************
***** COPY FILES *****
**********************/
$fail = -1;
if ($handle = opendir(osc_content_path() . 'downloads/oc-temp')) {
$folder_dest = ABS_PATH . "oc-content/" . $folder;
if (function_exists('posix_getpwuid')) {
$current_user = posix_getpwuid(posix_geteuid());
$ownerFolder = posix_getpwuid(fileowner($folder_dest));
}
$fail = 0;
while (false !== ($_file = readdir($handle))) {
if ($_file != '.' && $_file != '..') {
示例5: doModel
//.........这里部分代码省略.........
osc_add_flash_ok_message(_m('Plugin installed'), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
break;
case 'uninstall':
if (defined('DEMO')) {
osc_add_flash_warning_message(_m("This action cannot be done because is a demo site"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
}
if (Plugins::uninstall(Params::getParam("plugin"))) {
osc_add_flash_ok_message(_m('Plugin uninstalled'), 'admin');
} else {
osc_add_flash_error_message(_m("Plugin couldn't be uninstalled"), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
break;
case 'enable':
if (defined('DEMO')) {
osc_add_flash_warning_message(_m("This action cannot be done because is a demo site"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
}
if (Plugins::activate(Params::getParam('plugin'))) {
osc_add_flash_ok_message(_m('Plugin enabled'), 'admin');
} else {
osc_add_flash_error_message(_m('Plugin is already enabled'), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
break;
case 'disable':
if (defined('DEMO')) {
osc_add_flash_warning_message(_m("This action cannot be done because is a demo site"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
}
if (Plugins::deactivate(Params::getParam('plugin'))) {
osc_add_flash_ok_message(_m('Plugin disabled'), 'admin');
} else {
osc_add_flash_error_message(_m('Plugin is already disabled'), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
break;
case 'admin':
$plugin = Params::getParam("plugin");
if ($plugin != "") {
Plugins::runHook($plugin . '_configure');
}
break;
case 'admin_post':
Plugins::runHook('admin_post');
case 'renderplugin':
$file = Params::getParam("file");
if ($file != "") {
// We pass the GET variables (in case we have somes)
if (preg_match('|(.+?)\\?(.*)|', $file, $match)) {
$file = $match[1];
if (preg_match_all('|&([^=]+)=([^&]*)|', urldecode('&' . $match[2] . '&'), $get_vars)) {
for ($var_k = 0; $var_k < count($get_vars[1]); $var_k++) {
//$_GET[$get_vars[1][$var_k]] = $get_vars[2][$var_k];
//$_REQUEST[$get_vars[1][$var_k]] = $get_vars[2][$var_k];
Params::setParam($get_vars[1][$var_k], $get_vars[2][$var_k]);
}
}
} else {
$file = $_REQUEST['file'];
}
$this->_exportVariableToView("file", osc_plugins_path() . $file);
//osc_renderPluginView($file);
示例6: osc_market
function osc_market($section, $code)
{
$plugin = false;
$re_enable = false;
$message = "";
$data = array();
$download_post_data = array('api_key' => osc_market_api_connect());
/************************
*** CHECK VALID CODE ***
************************/
if ($code != '' && $section != '') {
if (stripos($code, "http://") === FALSE) {
// OSCLASS OFFICIAL REPOSITORY
$url = osc_market_url($section, $code);
$data = osc_file_get_contents($url, array('api_key' => osc_market_api_connect()));
$data = json_decode(osc_file_get_contents($url, array('api_key' => osc_market_api_connect())), true);
} else {
// THIRD PARTY REPOSITORY
if (osc_market_external_sources()) {
$download_post_data = array();
$data = json_decode(osc_file_get_contents($code), true);
} else {
return array('error' => 9, 'message' => __('No external sources are allowed'), 'data' => $data);
}
}
/***********************
**** DOWNLOAD FILE ****
***********************/
if (isset($data['s_update_url']) && isset($data['s_source_file']) && isset($data['e_type'])) {
if ($data['e_type'] == 'THEME') {
$folder = 'themes/';
} else {
if ($data['e_type'] == 'LANGUAGE') {
$folder = 'languages/';
} else {
// PLUGINS
$folder = 'plugins/';
$plugin = Plugins::findByUpdateURI($data['s_update_url']);
if ($plugin != false) {
if (Plugins::isEnabled($plugin)) {
Plugins::runHook($plugin . '_disable');
Plugins::deactivate($plugin);
$re_enable = true;
}
}
}
}
$filename = date('YmdHis') . "_" . osc_sanitize_string($data['s_title']) . "_" . $data['s_version'] . ".zip";
$url_source_file = $data['s_source_file'];
$result = osc_downloadFile($url_source_file, $filename, $download_post_data);
if ($result) {
// Everything is OK, continue
/**********************
***** UNZIP FILE *****
**********************/
@mkdir(osc_content_path() . 'downloads/oc-temp/');
$res = osc_unzip_file(osc_content_path() . 'downloads/' . $filename, osc_content_path() . 'downloads/oc-temp/');
if ($res == 1) {
// Everything is OK, continue
/**********************
***** COPY FILES *****
**********************/
$fail = -1;
if ($handle = opendir(osc_content_path() . 'downloads/oc-temp')) {
$folder_dest = ABS_PATH . "oc-content/" . $folder;
if (function_exists('posix_getpwuid')) {
$current_user = posix_getpwuid(posix_geteuid());
$ownerFolder = posix_getpwuid(fileowner($folder_dest));
}
$fail = 0;
while (false !== ($_file = readdir($handle))) {
if ($_file != '.' && $_file != '..') {
$copyprocess = osc_copy(osc_content_path() . "downloads/oc-temp/" . $_file, $folder_dest . $_file);
if ($copyprocess == false) {
$fail = 1;
}
}
}
closedir($handle);
// Additional actions is not important for the rest of the proccess
// We will inform the user of the problems but the upgrade could continue
// Also remove the zip package
/****************************
** REMOVE TEMPORARY FILES **
****************************/
@unlink(osc_content_path() . 'downloads/' . $filename);
$path = osc_content_path() . 'downloads/oc-temp';
$rm_errors = 0;
$dir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::CHILD_FIRST);
for ($dir->rewind(); $dir->valid(); $dir->next()) {
if ($dir->isDir()) {
if ($dir->getFilename() != '.' && $dir->getFilename() != '..') {
if (!rmdir($dir->getPathname())) {
$rm_errors++;
}
}
} else {
if (!unlink($dir->getPathname())) {
$rm_errors++;
}
//.........这里部分代码省略.........
示例7: doModel
//.........这里部分代码省略.........
break;
case 'uninstall':
if (defined('DEMO')) {
osc_add_flash_warning_message(_m("This action can't be done because it's a demo site"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
}
osc_csrf_check();
if (Plugins::uninstall(Params::getParam("plugin"))) {
osc_add_flash_ok_message(_m('Plugin uninstalled'), 'admin');
} else {
osc_add_flash_error_message(_m("Plugin couldn't be uninstalled"), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
break;
case 'enable':
if (defined('DEMO')) {
osc_add_flash_warning_message(_m("This action can't be done because it's a demo site"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
}
osc_csrf_check();
if (Plugins::activate(Params::getParam('plugin'))) {
osc_add_flash_ok_message(_m('Plugin enabled'), 'admin');
} else {
osc_add_flash_error_message(_m('Plugin is already enabled'), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
break;
case 'disable':
if (defined('DEMO')) {
osc_add_flash_warning_message(_m("This action can't be done because it's a demo site"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
}
osc_csrf_check();
if (Plugins::deactivate(Params::getParam('plugin'))) {
osc_add_flash_ok_message(_m('Plugin disabled'), 'admin');
} else {
osc_add_flash_error_message(_m('Plugin is already disabled'), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
break;
case 'admin':
$plugin = Params::getParam("plugin");
if ($plugin != "") {
Plugins::runHook($plugin . '_configure');
}
break;
case 'admin_post':
Plugins::runHook('admin_post');
break;
case 'renderplugin':
$file = Params::getParam("file");
if ($file != "") {
// We pass the GET variables (in case we have somes)
if (preg_match('|(.+?)\\?(.*)|', $file, $match)) {
$file = $match[1];
if (preg_match_all('|&([^=]+)=([^&]*)|', urldecode('&' . $match[2] . '&'), $get_vars)) {
for ($var_k = 0; $var_k < count($get_vars[1]); $var_k++) {
//$_GET[$get_vars[1][$var_k]] = $get_vars[2][$var_k];
//$_REQUEST[$get_vars[1][$var_k]] = $get_vars[2][$var_k];
Params::setParam($get_vars[1][$var_k], $get_vars[2][$var_k]);
}
}
} else {
$file = $_REQUEST['file'];
}
$this->_exportVariableToView("file", osc_plugins_path() . $file);
示例8: doModel
//.........这里部分代码省略.........
break;
case 'uninstall':
if (defined('DEMO')) {
osc_add_flash_warning_message(_m("This action can't be done because it's a demo site"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
}
osc_csrf_check();
if (Plugins::uninstall(Params::getParam("plugin"))) {
osc_add_flash_ok_message(_m('Plugin uninstalled'), 'admin');
} else {
osc_add_flash_error_message(_m("Plugin couldn't be uninstalled"), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
break;
case 'enable':
if (defined('DEMO')) {
osc_add_flash_warning_message(_m("This action can't be done because it's a demo site"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
}
osc_csrf_check();
if (Plugins::activate(Params::getParam('plugin'))) {
osc_add_flash_ok_message(_m('Plugin enabled'), 'admin');
} else {
osc_add_flash_error_message(_m('Plugin is already enabled'), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
break;
case 'disable':
if (defined('DEMO')) {
osc_add_flash_warning_message(_m("This action can't be done because it's a demo site"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
}
osc_csrf_check();
if (Plugins::deactivate(Params::getParam('plugin'))) {
osc_add_flash_ok_message(_m('Plugin disabled'), 'admin');
} else {
osc_add_flash_error_message(_m('Plugin is already disabled'), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
break;
case 'admin':
$plugin = Params::getParam("plugin");
if ($plugin != "") {
osc_run_hook($plugin . '_configure');
}
break;
case 'admin_post':
osc_run_hook('admin_post');
break;
case 'renderplugin':
if (Params::existParam('route')) {
$routes = Rewrite::newInstance()->getRoutes();
$rid = Params::getParam('route');
$file = '../';
if (isset($routes[$rid]) && isset($routes[$rid]['file'])) {
$file = $routes[$rid]['file'];
}
} else {
// DEPRECATED: Disclosed path in URL is deprecated, use routes instead
// This will be REMOVED in 3.4
$file = Params::getParam('file');
// We pass the GET variables (in case we have somes)
if (preg_match('|(.+?)\\?(.*)|', $file, $match)) {
$file = $match[1];
if (preg_match_all('|&([^=]+)=([^&]*)|', urldecode('&' . $match[2] . '&'), $get_vars)) {
for ($var_k = 0; $var_k < count($get_vars[1]); $var_k++) {
示例9: uninstall
static function uninstall($path)
{
$conn = getConnection();
$conn->autocommit(false);
try {
$data['s_value'] = osc_installed_plugins();
$plugins_list = unserialize($data['s_value']);
Plugins::deactivate($path);
$path = str_replace(osc_plugins_path(), '', $path);
if (is_array($plugins_list)) {
foreach ($plugins_list as $key => $value) {
if ($value == $path) {
unset($plugins_list[$key]);
}
}
$data['s_value'] = serialize($plugins_list);
$condition = array('s_section' => 'osclass', 's_name' => 'installed_plugins');
Preference::newInstance()->update($data, $condition);
unset($condition);
unset($data);
$conn->commit();
$plugin = Plugins::getInfo($path);
Plugins::cleanCategoryFromPlugin($plugin['short_name']);
}
} catch (Exception $e) {
$conn->rollback();
echo $e->getMessage();
}
$conn->autocommit(true);
}
示例10: deactivate
/**
* Деактивация плагина
*
* При деактивации плагина происходит запуск SQL из
* файла `plugin_path/install/drop.sql` и запуск файла
* `plugin_path/uninstall.php`
*
* @observer plugin_uninstall
* @return \Plugin_Decorator
*/
public function deactivate($run_script = FALSE)
{
$this->_status = (bool) DB::delete(self::TABLE_NAME)->where('id', '=', $this->id())->execute();
Plugins::deactivate($this);
$uninstall_file = $this->path() . 'uninstall' . EXT;
if ($run_script === TRUE and file_exists($uninstall_file)) {
Kohana::load($uninstall_file);
}
$drop_file = $this->path() . 'install' . DIRECTORY_SEPARATOR . 'drop.sql';
if (file_exists($drop_file)) {
Database_Helper::insert_sql(file_get_contents($drop_file));
}
Observer::notify('plugin_uninstall', $this->id());
$this->_on_deactivate();
return $this->_clear_cache();
}