forked from colakang/nyis_ask_wechat_plugin_backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
qa-rest-api-options.php
124 lines (98 loc) · 3.7 KB
/
qa-rest-api-options.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
class qa_rest_api_options_admin {
function allow_template($template) {
return ($template == 'admin');
}
function option_default($option) {
/*
* Internal security (non for third-party applications)
*
* if ($option == 'plugin_rest_api_permit') {
require_once QA_INCLUDE_DIR . 'qa-app-options.php';
return QA_PERMIT_EXPERTS;
} */
if ($option == 'plugin_rest_api_max_users')
return "10";
if ($option == 'plugin_rest_api_max_questions')
return "10";
if ($option == 'plugin_rest_api_max_answers')
return "10";
if ($option == 'plugin_rest_api_max_categories')
return "10";
if ($option == 'plugin_rest_api_max_tags')
return "10";
return null;
}
function admin_form(&$qa_content) {
require_once QA_INCLUDE_DIR . 'qa-app-admin.php';
require_once QA_INCLUDE_DIR . 'qa-app-options.php';
$permitoptions = qa_admin_permit_options ( QA_PERMIT_USERS, QA_PERMIT_SUPERS, false, false );
$elementoptions = array("10", "100", qa_lang_html('plugin_rest_api/rest_api_all'));
$saved = false;
if (qa_clicked ( 'plugin_rest_api_save_button' )) {
qa_opt ( 'plugin_rest_api_max_users', qa_post_text ( 'plugin_rest_api_mu_field' ) );
qa_opt ( 'plugin_rest_api_max_questions', qa_post_text ( 'plugin_rest_api_mq_field' ) );
qa_opt ( 'plugin_rest_api_max_answers', qa_post_text ( 'plugin_rest_api_ma_field' ) );
qa_opt ( 'plugin_rest_api_max_categories', qa_post_text ( 'plugin_rest_api_mc_field' ) );
qa_opt ( 'plugin_rest_api_max_tags', qa_post_text ( 'plugin_rest_api_mt_field' ) );
qa_opt ( 'plugin_rest_api_permit', ( int ) qa_post_text ( 'plugin_rest_api_p_field' ) );
$saved = true;
}
return array (
'ok' => $saved ? 'REST API settings saved' : null,
'fields' => array (
/*
* Internal security (non for third-party applications)
*
* array (
'label' => qa_lang_html('plugin_rest_api/rest_api_allow_use'),
'type' => 'select',
'value' => @$permitoptions [qa_opt ( 'plugin_rest_api_permit' )],
'options' => $permitoptions,
'tags' => 'NAME="plugin_rest_api_p_field"'
), */
array (
'label' => qa_lang_html('plugin_rest_api/rest_api_max_users'),
'type' => 'select',
'value' => @$elementoptions [qa_opt ( 'plugin_rest_api_max_users' )],
'options' => $elementoptions,
'tags' => 'NAME="plugin_rest_api_mu_field"'
),
array (
'label' => qa_lang_html('plugin_rest_api/rest_api_max_questions'),
'type' => 'select',
'value' => @$elementoptions [qa_opt ( 'plugin_rest_api_max_questions' )],
'options' => $elementoptions,
'tags' => 'NAME="plugin_rest_api_mq_field"'
),
array (
'label' => qa_lang_html('plugin_rest_api/rest_api_max_answers'),
'type' => 'select',
'value' => @$elementoptions [qa_opt ( 'plugin_rest_api_max_answers' )],
'options' => $elementoptions,
'tags' => 'NAME="plugin_rest_api_ma_field"'
),
array (
'label' => qa_lang_html('plugin_rest_api/rest_api_max_categories'),
'type' => 'select',
'value' => @$elementoptions [qa_opt ( 'plugin_rest_api_max_categories' )],
'options' => $elementoptions,
'tags' => 'NAME="plugin_rest_api_mc_field"'
),
array (
'label' => qa_lang_html('plugin_rest_api/rest_api_max_tags'),
'type' => 'select',
'value' => @$elementoptions [qa_opt ( 'plugin_rest_api_max_tags' )],
'options' => $elementoptions,
'tags' => 'NAME="plugin_rest_api_mt_field"'
)
),
'buttons' => array (
array (
'label' => 'Save Changes',
'tags' => 'NAME="plugin_rest_api_save_button"'
)
)
);
}
}