Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
question2answer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
outils
question2answer
Commits
4ac3db2a
Unverified
Commit
4ac3db2a
authored
Dec 08, 2018
by
Scott
Committed by
GitHub
Dec 08, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #672 from pupi1985/patch-118
Turn all remaining AJAX calls in admin into JSON
parents
1b3b746f
3699ec82
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
75 additions
and
61 deletions
+75
-61
qa-admin.js
qa-content/qa-admin.js
+27
-32
qa-global.js
qa-content/qa-global.js
+6
-6
mailing.php
qa-include/ajax/mailing.php
+12
-6
recalc.php
qa-include/ajax/recalc.php
+5
-4
version.php
qa-include/ajax/version.php
+24
-12
install.php
qa-include/db/install.php
+1
-1
No files found.
qa-content/qa-admin.js
View file @
4ac3db2a
...
...
@@ -56,28 +56,21 @@ function qa_recalc_update(elem, state, noteid)
{
if
(
state
)
{
var
recalcCode
=
elem
.
form
.
elements
.
code_recalc
?
elem
.
form
.
elements
.
code_recalc
.
value
:
elem
.
form
.
elements
.
code
.
value
;
qa_ajax_post
(
'recalc'
,
{
state
:
state
,
code
:
recalcCode
},
function
(
lines
)
{
if
(
lines
[
0
]
==
'1'
)
{
if
(
lines
[
2
])
document
.
getElementById
(
noteid
).
innerHTML
=
lines
[
2
];
if
(
elem
.
qa_recalc_stopped
)
qa_recalc_cleanup
(
elem
);
else
qa_recalc_update
(
elem
,
lines
[
1
],
noteid
);
function
(
response
)
{
if
(
response
.
message
)
{
document
.
getElementById
(
noteid
).
innerHTML
=
response
.
message
;
}
}
else
if
(
lines
[
0
]
==
'0'
)
{
document
.
getElementById
(
noteid
).
innerHTML
=
lines
[
1
];
if
(
elem
.
qa_recalc_stopped
)
{
qa_recalc_cleanup
(
elem
);
}
else
{
qa_ajax_error
();
qa_recalc_cleanup
(
elem
);
}
qa_recalc_update
(
elem
,
response
.
state
,
noteid
);
}
},
1
);
}
else
{
qa_recalc_cleanup
(
elem
);
...
...
@@ -93,22 +86,19 @@ function qa_recalc_cleanup(elem)
function
qa_mailing_start
(
noteid
,
pauseid
)
{
qa_ajax_post
(
'mailing'
,
{},
function
(
lines
)
{
if
(
lines
[
0
]
==
'1'
)
{
document
.
getElementById
(
noteid
).
innerHTML
=
lines
[
1
];
window
.
setTimeout
(
function
()
{
qa_ajax_post
(
'mailing'
,
{},
function
(
response
)
{
document
.
getElementById
(
noteid
).
innerHTML
=
response
.
message
;
if
(
response
.
continue
)
{
window
.
setTimeout
(
function
()
{
qa_mailing_start
(
noteid
,
pauseid
);
},
1
);
// don't recurse
}
else
if
(
lines
[
0
]
==
'0'
)
{
document
.
getElementById
(
noteid
).
innerHTML
=
lines
[
1
];
document
.
getElementById
(
pauseid
).
style
.
display
=
'none'
;
}
else
{
qa_ajax_error
();
}
document
.
getElementById
(
pauseid
).
style
.
display
=
'none'
;
}
},
1
);
}
...
...
@@ -159,13 +149,18 @@ function qa_admin_click(target)
function
qa_version_check
(
uri
,
version
,
elem
,
isCore
)
{
var
params
=
{
uri
:
uri
,
version
:
version
,
isCore
:
isCore
};
qa_ajax_post
(
'version'
,
{
uri
:
uri
,
version
:
version
,
isCore
:
isCore
},
function
(
response
)
{
if
(
response
.
result
===
'error'
)
{
alert
(
response
.
error
.
message
);
qa_ajax_post
(
'version'
,
params
,
function
(
lines
)
{
if
(
lines
[
0
]
==
'1'
)
document
.
getElementById
(
elem
).
innerHTML
=
lines
[
1
];
return
;
}
document
.
getElementById
(
elem
).
innerHTML
=
response
.
html
;
},
1
);
}
...
...
qa-content/qa-global.js
View file @
4ac3db2a
...
...
@@ -152,16 +152,16 @@ function qa_favorite_click(elem)
return
false
;
}
function
qa_ajax_post
(
operation
,
params
,
callback
,
v
ersion
)
function
qa_ajax_post
(
operation
,
params
,
callback
,
apiV
ersion
)
{
if
(
typeof
(
v
ersion
)
===
'undefined'
)
{
v
ersion
=
0
;
if
(
typeof
(
apiV
ersion
)
===
'undefined'
)
{
apiV
ersion
=
0
;
}
$
.
extend
(
params
,
{
qa
:
'ajax'
,
qa_operation
:
operation
,
qa_root
:
qa_root
,
qa_request
:
qa_request
,
version
:
v
ersion
});
$
.
extend
(
params
,
{
qa
:
'ajax'
,
qa_operation
:
operation
,
qa_root
:
qa_root
,
qa_request
:
qa_request
,
apiVersion
:
apiV
ersion
});
$
.
post
(
qa_root
,
params
,
function
(
response
)
{
if
(
v
ersion
===
0
)
{
if
(
apiV
ersion
===
0
)
{
var
header
=
'QA_AJAX_RESPONSE'
;
var
headerpos
=
response
.
indexOf
(
header
);
...
...
@@ -173,7 +173,7 @@ function qa_ajax_post(operation, params, callback, version)
callback
(
response
);
}
},
v
ersion
===
0
?
'text'
:
'json'
apiV
ersion
===
0
?
'text'
:
'json'
).
fail
(
function
(
jqXHR
)
{
if
(
jqXHR
.
readyState
>
0
)
qa_ajax_error
();
...
...
qa-include/ajax/mailing.php
View file @
4ac3db2a
...
...
@@ -30,18 +30,24 @@ if (qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) {
qa_mailing_perform_step
();
if
(
$starttime
==
time
())
if
(
$starttime
==
time
())
{
sleep
(
1
);
// make sure at least one second has passed
}
$message
=
qa_mailing_progress_message
();
if
(
isset
(
$message
))
if
(
isset
(
$message
))
{
$continue
=
true
;
else
}
else
{
$message
=
qa_lang
(
'admin/mailing_complete'
);
}
else
}
}
else
{
$message
=
qa_lang
(
'admin/no_privileges'
);
}
$response
=
array
(
'continue'
=>
$continue
,
'message'
=>
qa_html
(
$message
),
);
echo
"QA_AJAX_RESPONSE
\n
"
.
(
int
)
$continue
.
"
\n
"
.
qa_html
(
$messag
e
);
echo
json_encode
(
$respons
e
);
qa-include/ajax/recalc.php
View file @
4ac3db2a
...
...
@@ -26,7 +26,6 @@ if (qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) {
if
(
!
qa_check_form_security_code
(
'admin/recalc'
,
qa_post_text
(
'code'
)))
{
$state
=
''
;
$message
=
qa_lang
(
'misc/form_security_reload'
);
}
else
{
$recalc
=
new
\Q2A\Recalc\RecalcMain
(
qa_post_text
(
'state'
));
$stoptime
=
time
()
+
3
;
...
...
@@ -37,13 +36,15 @@ if (qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) {
$message
=
$recalc
->
getMessage
();
$state
=
$recalc
->
getState
();
}
}
else
{
$state
=
''
;
$message
=
qa_lang
(
'admin/no_privileges'
);
}
$response
=
array
(
'state'
=>
$state
,
'message'
=>
qa_html
(
$message
),
);
echo
"QA_AJAX_RESPONSE
\n
1
\n
"
.
$state
.
"
\n
"
.
qa_html
(
$messag
e
);
echo
json_encode
(
$respons
e
);
qa-include/ajax/version.php
View file @
4ac3db2a
...
...
@@ -23,28 +23,35 @@ require_once QA_INCLUDE_DIR . 'app/admin.php';
require_once
QA_INCLUDE_DIR
.
'app/users.php'
;
if
(
qa_get_logged_in_level
()
<
QA_USER_LEVEL_ADMIN
)
{
echo
"QA_AJAX_RESPONSE
\n
0
\n
"
.
qa_lang_html
(
'admin/no_privileges'
);
$response
=
array
(
'result'
=>
'error'
,
'error'
=>
array
(
'message'
=>
qa_lang_html
(
'admin/no_privileges'
),
),
);
echo
json_encode
(
$response
);
return
;
}
$uri
=
qa_post_text
(
'uri'
);
$version
=
qa_post_text
(
'version'
);
$isCore
=
qa_post_text
(
'isCore'
)
===
"true"
;
$isCore
=
qa_post_text
(
'isCore'
)
===
'true'
;
if
(
$isCore
)
{
$contents
=
qa_retrieve_url
(
$uri
);
if
(
strlen
(
$contents
)
>
0
)
{
if
(
qa_qa_version_below
(
$contents
))
{
$
r
esponse
=
$
versionR
esponse
=
'<a href="https://github.com/q2a/question2answer/releases" style="color:#d00;">'
.
qa_lang_html_sub
(
'admin/version_get_x'
,
qa_html
(
'v'
.
$contents
))
.
'</a>'
;
}
else
{
$
r
esponse
=
qa_html
(
$contents
);
// Output the current version number
$
versionR
esponse
=
qa_html
(
$contents
);
// Output the current version number
}
}
else
{
$
r
esponse
=
qa_lang_html
(
'admin/version_latest_unknown'
);
$
versionR
esponse
=
qa_lang_html
(
'admin/version_latest_unknown'
);
}
}
else
{
$metadataUtil
=
new
Q2A_Util_Metadata
();
...
...
@@ -53,28 +60,33 @@ if ($isCore) {
if
(
strlen
(
@
$metadata
[
'version'
])
>
0
)
{
if
(
strcmp
(
$metadata
[
'version'
],
$version
))
{
if
(
qa_qa_version_below
(
@
$metadata
[
'min_q2a'
]))
{
$
r
esponse
=
strtr
(
qa_lang_html
(
'admin/version_requires_q2a'
),
array
(
$
versionR
esponse
=
strtr
(
qa_lang_html
(
'admin/version_requires_q2a'
),
array
(
'^1'
=>
qa_html
(
'v'
.
$metadata
[
'version'
]),
'^2'
=>
qa_html
(
$metadata
[
'min_q2a'
]),
));
}
elseif
(
qa_php_version_below
(
@
$metadata
[
'min_php'
]))
{
$
r
esponse
=
strtr
(
qa_lang_html
(
'admin/version_requires_php'
),
array
(
$
versionR
esponse
=
strtr
(
qa_lang_html
(
'admin/version_requires_php'
),
array
(
'^1'
=>
qa_html
(
'v'
.
$metadata
[
'version'
]),
'^2'
=>
qa_html
(
$metadata
[
'min_php'
]),
));
}
else
{
$
r
esponse
=
qa_lang_html_sub
(
'admin/version_get_x'
,
qa_html
(
'v'
.
$metadata
[
'version'
]));
$
versionR
esponse
=
qa_lang_html_sub
(
'admin/version_get_x'
,
qa_html
(
'v'
.
$metadata
[
'version'
]));
if
(
strlen
(
@
$metadata
[
'uri'
]))
{
$
response
=
'<a href="'
.
qa_html
(
$metadata
[
'uri'
])
.
'" style="color:#d00;">'
.
$r
esponse
.
'</a>'
;
$
versionResponse
=
'<a href="'
.
qa_html
(
$metadata
[
'uri'
])
.
'" style="color:#d00;">'
.
$versionR
esponse
.
'</a>'
;
}
}
}
else
{
$
r
esponse
=
qa_lang_html
(
'admin/version_latest'
);
$
versionR
esponse
=
qa_lang_html
(
'admin/version_latest'
);
}
}
else
{
$
r
esponse
=
qa_lang_html
(
'admin/version_latest_unknown'
);
$
versionR
esponse
=
qa_lang_html
(
'admin/version_latest_unknown'
);
}
}
echo
"QA_AJAX_RESPONSE
\n
1
\n
"
.
$response
;
$response
=
array
(
'result'
=>
'success'
,
'html'
=>
$versionResponse
,
);
echo
json_encode
(
$response
);
qa-include/db/install.php
View file @
4ac3db2a
...
...
@@ -1621,7 +1621,7 @@ function qa_db_upgrade_tables()
while
(
$recalc
->
performStep
()
&&
(
time
()
<
$stoptime
))
;
qa_db_upgrade_progress
(
$recalc
->
getM
m
essage
());
qa_db_upgrade_progress
(
$recalc
->
getMessage
());
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment