PluginProbe
Migrate to WordPress.com / 5.88
Migrate to WordPress.com v5.88
6.72 6.65 trunk 5.72 5.81 5.88
wpcom-migration / callback / wings / account.php

account.php in Migrate to WordPress.com 5.88, at callback/wings/account.php

96 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (!defined('ABSPATH')) exit;
4 if (!class_exists('BVAccountCallback')) :
5 class BVAccountCallback extends BVCallbackBase {
6 public $account;
7 public $settings;
8
9 const ACCOUNT_WING_VERSION = 1.2;
10
11 public function __construct($callback_handler) {
12 $this->account = $callback_handler->account;
13 $this->settings = $callback_handler->settings;
14 }
15
16 function updateInfo($args) {
17 $result = array();
18
19 if (array_key_exists('update_info', $args)) {
20 $this->account->updateInfo($args['update_info']);
21 $result['update_info'] = array(
22 "status" => WPCOMAccount::exists($this->settings, $args['update_info']['pubkey'])
23 );
24 }
25
26 if (array_key_exists('update_api_key', $args)) {
27 WPCOMAccount::updateApiPublicKey($this->settings, $args['update_api_key']['pubkey']);
28 $result['update_api_key'] = array(
29 "status" => $this->settings->getOption(WPCOMAccount::$api_public_key)
30 );
31 }
32
33 if (array_key_exists('update_options', $args))
34 $result['update_options'] = $this->settings->updateOptions($args['update_options']);
35
36 if (array_key_exists('delete_options', $args))
37 $result['delete_options'] = $this->settings->deleteOptions($args['delete_options']);
38
39 $result['status'] = true;
40
41 return $result;
42 }
43
44 function process($request) {
45 $params = $request->params;
46 $account = $this->account;
47 $settings = $this->settings;
48 switch ($request->method) {
49 case "addacc":
50 WPCOMAccount::addAccount($settings, $params['public'], $params['secret']);
51 $resp = array("status" => WPCOMAccount::exists($settings, $params['public']));
52 break;
53 case "rmacc":
54 $resp = array("status" => WPCOMAccount::remove($settings, $params['public']));
55 break;
56 case "updt":
57 $account->updateInfo($params);
58 $resp = array("status" => WPCOMAccount::exists($settings, $params['pubkey']));
59 break;
60 case "updtapikey":
61 WPCOMAccount::updateApiPublicKey($settings, $params['pubkey']);
62 $resp = array("status" => $settings->getOption(WPCOMAccount::$api_public_key));
63 break;
64 case "rmbvscrt":
65 $resp = array("status" => WPCOMRecover::deleteDefaultSecret($settings));
66 break;
67 case "rmbvkeys":
68 $resp = array("status" => $settings->deleteOption('bvKeys'));
69 break;
70 case "rmdefpub":
71 $resp = array("status" => $settings->deleteOption('bvDefaultPublic'));
72 break;
73 case "rmoldbvacc":
74 $resp = array("status" => $settings->deleteOption('bvAccounts'));
75 break;
76 case "fetch":
77 $accounts = WPCOMAccount::allAccounts($settings);
78 if (!isset($params['full'])) {
79 foreach ($accounts as &$account) {
80 if (isset($account['secret'])) {
81 unset($account['secret']);
82 }
83 }
84 }
85 $resp = array("status" => $accounts);
86 break;
87 case "updtinfo":
88 $resp = $this->updateInfo($params);
89 break;
90 default:
91 $resp = false;
92 }
93 return $resp;
94 }
95 }
96 endif;