| | 2467 | |
| | 2468 | function ws_plugins_getList($params, &$service) |
| | 2469 | { |
| | 2470 | global $conf; |
| | 2471 | |
| | 2472 | if (!is_admin()) |
| | 2473 | { |
| | 2474 | return new PwgError(401, 'Access denied'); |
| | 2475 | } |
| | 2476 | |
| | 2477 | include_once(PHPWG_ROOT_PATH.'admin/include/plugins.class.php'); |
| | 2478 | $plugins = new plugins(); |
| | 2479 | $plugins->sort_fs_plugins('name'); |
| | 2480 | $plugin_list = array(); |
| | 2481 | |
| | 2482 | foreach($plugins->fs_plugins as $plugin_id => $fs_plugin) |
| | 2483 | { |
| | 2484 | if (isset($plugins->db_plugins_by_id[$plugin_id])) |
| | 2485 | { |
| | 2486 | $state = $plugins->db_plugins_by_id[$plugin_id]['state']; |
| | 2487 | } |
| | 2488 | else |
| | 2489 | { |
| | 2490 | $state = 'uninstalled'; |
| | 2491 | } |
| | 2492 | |
| | 2493 | array_push( |
| | 2494 | $plugin_list, |
| | 2495 | array( |
| | 2496 | 'id' => $plugin_id, |
| | 2497 | 'name' => $fs_plugin['name'], |
| | 2498 | 'version' => $fs_plugin['version'], |
| | 2499 | 'state' => $state, |
| | 2500 | 'description' => $fs_plugin['description'], |
| | 2501 | ) |
| | 2502 | ); |
| | 2503 | } |
| | 2504 | |
| | 2505 | return $plugin_list; |
| | 2506 | } |
| | 2507 | |
| | 2508 | function ws_plugins_performAction($params, &$service) |
| | 2509 | { |
| | 2510 | global $template; |
| | 2511 | |
| | 2512 | if (!is_admin()) |
| | 2513 | { |
| | 2514 | return new PwgError(401, 'Access denied'); |
| | 2515 | } |
| | 2516 | |
| | 2517 | if (empty($params['pwg_token']) or get_pwg_token() != $params['pwg_token']) |
| | 2518 | { |
| | 2519 | return new PwgError(403, 'Invalid security token'); |
| | 2520 | } |
| | 2521 | |
| | 2522 | define('IN_ADMIN', true); |
| | 2523 | include_once(PHPWG_ROOT_PATH.'admin/include/plugins.class.php'); |
| | 2524 | $plugins = new plugins(); |
| | 2525 | $errors = $plugins->perform_action($params['action'], $params['plugin']); |
| | 2526 | |
| | 2527 | |
| | 2528 | if (!empty($errors)) |
| | 2529 | { |
| | 2530 | return new PwgError(500, $errors); |
| | 2531 | } |
| | 2532 | else |
| | 2533 | { |
| | 2534 | if (in_array($params['action'], array('activate', 'deactivate'))) |
| | 2535 | { |
| | 2536 | $template->delete_compiled_templates(); |
| | 2537 | } |
| | 2538 | return true; |
| | 2539 | } |
| | 2540 | } |
| | 2541 | |