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
5baf8603
Commit
5baf8603
authored
Mar 19, 2018
by
pupi1985
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use DOM updates controlled by the backend
parent
ac8b85cb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
100 additions
and
27 deletions
+100
-27
qa-admin.js
qa-content/qa-admin.js
+23
-5
click-admin.php
qa-include/ajax/click-admin.php
+0
-1
admin.php
qa-include/app/admin.php
+77
-21
No files found.
qa-content/qa-admin.js
View file @
5baf8603
...
...
@@ -112,6 +112,27 @@ function qa_mailing_start(noteid, pauseid)
);
}
function
qa_update_dom
(
response
)
{
if
(
!
response
.
hasOwnProperty
(
'domUpdates'
))
{
return
;
}
for
(
var
i
=
0
;
i
<
response
.
domUpdates
.
length
;
i
++
)
{
var
domUpdate
=
response
.
domUpdates
[
i
];
switch
(
domUpdate
.
action
)
{
case
'conceal'
:
qa_conceal
(
document
.
querySelector
(
domUpdate
.
selector
));
break
;
case
'reveal'
:
qa_reveal
(
document
.
querySelector
(
domUpdate
.
selector
));
break
;
default
:
// replace
$
(
domUpdate
.
selector
).
html
(
domUpdate
.
html
);
}
}
}
function
qa_admin_click
(
target
)
{
var
p
=
target
.
name
.
split
(
'_'
);
...
...
@@ -121,12 +142,9 @@ function qa_admin_click(target)
qa_ajax_post
(
'click_admin'
,
params
,
function
(
response
)
{
if
(
response
.
hideEntitySelector
!==
null
)
{
qa_conceal
(
document
.
getElementById
(
'p'
+
params
.
entityid
),
'admin'
);
$
(
'.qa-nav-sub-counter-'
+
response
.
hideEntitySelector
).
text
(
response
.
entityCount
);
}
qa_update_dom
(
response
);
if
(
response
.
result
!==
'success
'
)
{
if
(
response
.
result
===
'error'
&&
response
.
error
.
severity
===
'fatal
'
)
{
alert
(
response
.
error
.
message
);
}
...
...
qa-include/ajax/click-admin.php
View file @
5baf8603
...
...
@@ -52,4 +52,3 @@ switch ($version) {
else
echo
"QA_AJAX_RESPONSE
\n
0
\n
"
.
qa_lang
(
'main/general_error'
);
}
qa-include/app/admin.php
View file @
5baf8603
...
...
@@ -602,19 +602,25 @@ function qa_admin_single_click_array($entityid, $action)
if
(
isset
(
$useraccount
)
&&
qa_get_logged_in_level
()
>=
QA_USER_LEVEL_MODERATOR
)
{
switch
(
$action
)
{
case
'userapprove'
:
$response
[
'entityCount'
]
=
(
int
)
qa_opt
(
'cache_uapprovecount'
);
if
(
$useraccount
[
'level'
]
>=
QA_USER_LEVEL_APPROVED
)
{
// don't demote higher level users
$response
[
'result'
]
=
'error'
;
$response
[
'error'
][
'type'
]
=
'user-already-approved'
;
$response
[
'error'
][
'message'
]
=
qa_lang_html
(
'main/general_error'
);
$response
[
'hideEntitySelector'
]
=
null
;
}
else
{
require_once
QA_INCLUDE_DIR
.
'app/users-edit.php'
;
qa_set_user_level
(
$useraccount
[
'userid'
],
$useraccount
[
'handle'
],
QA_USER_LEVEL_APPROVED
,
$useraccount
[
'level'
]);
$response
[
'result'
]
=
'success'
;
$response
[
'entityCount'
]
=
max
(
$response
[
'entityCount'
]
-
1
,
0
);
$response
[
'hideEntitySelector'
]
=
'approve'
;
$response
[
'domUpdates'
]
=
array
(
array
(
'selector'
=>
'.qa-nav-sub-counter-approve'
,
'html'
=>
max
((
int
)
qa_opt
(
'cache_uapprovecount'
)
-
1
,
0
),
),
array
(
'selector'
=>
'#p'
.
$entityid
,
'action'
=>
'conceal'
,
),
);
}
break
;
...
...
@@ -623,8 +629,16 @@ function qa_admin_single_click_array($entityid, $action)
qa_set_user_blocked
(
$useraccount
[
'userid'
],
$useraccount
[
'handle'
],
true
);
$response
[
'result'
]
=
'success'
;
$response
[
'entityCount'
]
=
max
((
int
)
qa_opt
(
'cache_uapprovecount'
)
-
1
,
0
);
$response
[
'hideEntitySelector'
]
=
'approve'
;
$response
[
'domUpdates'
]
=
array
(
array
(
'selector'
=>
'.qa-nav-sub-counter-approve'
,
'html'
=>
max
((
int
)
qa_opt
(
'cache_uapprovecount'
)
-
1
,
0
),
),
array
(
'selector'
=>
'#p'
.
$entityid
,
'action'
=>
'conceal'
,
),
);
break
;
default
:
...
...
@@ -641,18 +655,26 @@ function qa_admin_single_click_array($entityid, $action)
switch
(
$action
)
{
case
'approve'
:
case
'reject'
:
$
response
[
'entityCount'
]
=
(
int
)
qa_opt
(
'cache_queuedcount'
);
$
entityCount
=
(
int
)
qa_opt
(
'cache_queuedcount'
);
if
(
!
$queued
)
{
$response
[
'result'
]
=
'error'
;
$response
[
'error'
][
'type'
]
=
'post-not-queued'
;
$response
[
'error'
][
'message'
]
=
qa_lang_html
(
'main/general_error'
);
$response
[
'entityCount'
]
=
max
(
$response
[
'entityCount'
]
-
1
,
0
);
$response
[
'hideEntitySelector'
]
=
'moderate'
;
$response
[
'domUpdates'
]
=
array
(
array
(
'selector'
=>
'.qa-nav-sub-counter-moderate'
,
'html'
=>
max
(
$entityCount
-
1
,
0
),
),
array
(
'selector'
=>
'#p'
.
$entityid
,
'action'
=>
'conceal'
,
),
);
}
elseif
(
qa_user_post_permit_error
(
'permit_moderate'
,
$post
)
!==
false
)
{
$response
[
'result'
]
=
'error'
;
$response
[
'error'
][
'type'
]
=
'no-permission'
;
$response
[
'error'
][
'message'
]
=
qa_lang_html
(
'users/no_permission'
);
$response
[
'
hideEntitySelector'
]
=
null
;
$response
[
'
error'
][
'severity'
]
=
'fatal'
;
}
else
{
$postStatus
=
$action
===
'approve'
?
QA_POST_STATUS_NORMAL
...
...
@@ -660,8 +682,16 @@ function qa_admin_single_click_array($entityid, $action)
qa_post_set_status
(
$entityid
,
$postStatus
,
$userid
);
$response
[
'result'
]
=
'success'
;
$response
[
'entityCount'
]
=
max
(
$response
[
'entityCount'
]
-
1
,
0
);
$response
[
'hideEntitySelector'
]
=
'moderate'
;
$response
[
'domUpdates'
]
=
array
(
array
(
'selector'
=>
'.qa-nav-sub-counter-moderate'
,
'html'
=>
max
(
$entityCount
-
1
,
0
),
),
array
(
'selector'
=>
'#p'
.
$entityid
,
'action'
=>
'conceal'
,
),
);
}
break
;
...
...
@@ -671,12 +701,17 @@ function qa_admin_single_click_array($entityid, $action)
$response
[
'result'
]
=
'error'
;
$response
[
'error'
][
'type'
]
=
'post-not-hidden'
;
$response
[
'error'
][
'message'
]
=
qa_lang_html
(
'main/general_error'
);
$response
[
'hideEntitySelector'
]
=
'hidden'
;
$response
[
'domUpdates'
]
=
array
(
array
(
'selector'
=>
'#p'
.
$entityid
,
'action'
=>
'conceal'
,
),
);
}
elseif
(
qa_user_post_permit_error
(
'permit_hide_show'
,
$post
)
!==
false
)
{
$response
[
'result'
]
=
'error'
;
$response
[
'error'
][
'type'
]
=
'no-permission'
;
$response
[
'error'
][
'message'
]
=
qa_lang_html
(
'users/no_permission'
);
$response
[
'
hideEntitySelector'
]
=
null
;
$response
[
'
error'
][
'severity'
]
=
'fatal'
;
}
else
{
if
(
$action
===
'reshow'
)
{
qa_post_set_status
(
$entityid
,
QA_POST_STATUS_NORMAL
,
$userid
);
...
...
@@ -685,24 +720,37 @@ function qa_admin_single_click_array($entityid, $action)
}
$response
[
'result'
]
=
'success'
;
$response
[
'hideEntitySelector'
]
=
'hidden'
;
$response
[
'domUpdates'
]
=
array
(
array
(
'selector'
=>
'#p'
.
$entityid
,
'action'
=>
'conceal'
,
),
);
}
break
;
case
'hide'
:
case
'clearflags'
:
$
response
[
'entityCount'
]
=
(
int
)
qa_opt
(
'cache_flaggedcount'
);
$
entityCount
=
(
int
)
qa_opt
(
'cache_flaggedcount'
);
if
(
$action
===
'hide'
&&
$queued
)
{
$response
[
'result'
]
=
'error'
;
$response
[
'error'
][
'type'
]
=
'post-queued'
;
$response
[
'error'
][
'message'
]
=
qa_lang_html
(
'main/general_error'
);
$response
[
'entityCount'
]
=
max
(
$response
[
'entityCount'
]
-
1
,
0
);
$response
[
'hideEntitySelector'
]
=
'flagged'
;
$response
[
'domUpdates'
]
=
array
(
array
(
'selector'
=>
'.qa-nav-sub-counter-flagged'
,
'html'
=>
max
(
$entityCount
-
1
,
0
),
),
array
(
'selector'
=>
'#p'
.
$entityid
,
'action'
=>
'conceal'
,
),
);
}
elseif
(
qa_user_post_permit_error
(
'permit_hide_show'
,
$post
)
!==
false
)
{
$response
[
'result'
]
=
'error'
;
$response
[
'error'
][
'type'
]
=
'no-permission'
;
$response
[
'error'
][
'message'
]
=
qa_lang_html
(
'users/no_permission'
);
$response
[
'
hideEntitySelector'
]
=
null
;
$response
[
'
error'
][
'severity'
]
=
'fatal'
;
}
else
{
if
(
$action
===
'hide'
)
{
qa_post_set_status
(
$entityid
,
QA_POST_STATUS_HIDDEN
,
$userid
);
...
...
@@ -713,8 +761,16 @@ function qa_admin_single_click_array($entityid, $action)
}
$response
[
'result'
]
=
'success'
;
$response
[
'entityCount'
]
=
max
(
$response
[
'entityCount'
]
-
1
,
0
);
$response
[
'hideEntitySelector'
]
=
'flagged'
;
$response
[
'domUpdates'
]
=
array
(
array
(
'selector'
=>
'.qa-nav-sub-counter-flagged'
,
'html'
=>
max
(
$entityCount
-
1
,
0
),
),
array
(
'selector'
=>
'#p'
.
$entityid
,
'action'
=>
'conceal'
,
),
);
}
break
;
...
...
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