diff options
author | plegall <plg@piwigo.org> | 2010-12-23 23:12:03 +0000 |
---|---|---|
committer | plegall <plg@piwigo.org> | 2010-12-23 23:12:03 +0000 |
commit | ae5438fbcef2764ad86261c0468c2c695a14aba4 (patch) | |
tree | 273194676ea8861fe33e53b2130d7e8cfa85a428 /include | |
parent | c1d517c285f7e159c877bf89c0ce12ad6f701461 (diff) |
feature 2084 added: new method pwg.plugins.getList and pwg.plugins.performAction
git-svn-id: http://piwigo.org/svn/trunk@8273 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r-- | include/ws_functions.inc.php | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php index 61e8e1a01..0bbab914f 100644 --- a/include/ws_functions.inc.php +++ b/include/ws_functions.inc.php @@ -2464,4 +2464,79 @@ function ws_images_checkUpload($params, &$service) return $ret; } + +function ws_plugins_getList($params, &$service) +{ + global $conf; + + if (!is_admin()) + { + return new PwgError(401, 'Access denied'); + } + + include_once(PHPWG_ROOT_PATH.'admin/include/plugins.class.php'); + $plugins = new plugins(); + $plugins->sort_fs_plugins('name'); + $plugin_list = array(); + + foreach($plugins->fs_plugins as $plugin_id => $fs_plugin) + { + if (isset($plugins->db_plugins_by_id[$plugin_id])) + { + $state = $plugins->db_plugins_by_id[$plugin_id]['state']; + } + else + { + $state = 'uninstalled'; + } + + array_push( + $plugin_list, + array( + 'id' => $plugin_id, + 'name' => $fs_plugin['name'], + 'version' => $fs_plugin['version'], + 'state' => $state, + 'description' => $fs_plugin['description'], + ) + ); + } + + return $plugin_list; +} + +function ws_plugins_performAction($params, &$service) +{ + global $template; + + if (!is_admin()) + { + return new PwgError(401, 'Access denied'); + } + + if (empty($params['pwg_token']) or get_pwg_token() != $params['pwg_token']) + { + return new PwgError(403, 'Invalid security token'); + } + + define('IN_ADMIN', true); + include_once(PHPWG_ROOT_PATH.'admin/include/plugins.class.php'); + $plugins = new plugins(); + $errors = $plugins->perform_action($params['action'], $params['plugin']); + + + if (!empty($errors)) + { + return new PwgError(500, $errors); + } + else + { + if (in_array($params['action'], array('activate', 'deactivate'))) + { + $template->delete_compiled_templates(); + } + return true; + } +} + ?> |