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
1b3b746f
Unverified
Commit
1b3b746f
authored
Dec 08, 2018
by
Scott
Committed by
GitHub
Dec 08, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #608 from pupi1985/patch-104
Use JSON in admin_click AJAX calls
parents
04fd4dc4
c6bce760
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
353 additions
and
32 deletions
+353
-32
qa-admin.js
qa-content/qa-admin.js
+29
-8
qa-global.js
qa-content/qa-global.js
+15
-6
click-admin.php
qa-include/ajax/click-admin.php
+12
-6
admin.php
qa-include/app/admin.php
+260
-7
post-update.php
qa-include/app/post-update.php
+15
-0
post-create.php
qa-include/db/post-create.php
+16
-0
qa-lang-admin.php
qa-include/lang/qa-lang-admin.php
+5
-4
admin-approve.php
qa-include/pages/admin/admin-approve.php
+1
-1
No files found.
qa-content/qa-admin.js
View file @
1b3b746f
...
@@ -112,6 +112,27 @@ function qa_mailing_start(noteid, pauseid)
...
@@ -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
)
function
qa_admin_click
(
target
)
{
{
var
p
=
target
.
name
.
split
(
'_'
);
var
p
=
target
.
name
.
split
(
'_'
);
...
@@ -120,15 +141,15 @@ function qa_admin_click(target)
...
@@ -120,15 +141,15 @@ function qa_admin_click(target)
params
.
code
=
target
.
form
.
elements
.
code
.
value
;
params
.
code
=
target
.
form
.
elements
.
code
.
value
;
qa_ajax_post
(
'click_admin'
,
params
,
qa_ajax_post
(
'click_admin'
,
params
,
function
(
lines
)
{
function
(
response
)
{
if
(
lines
[
0
]
==
'1'
)
qa_update_dom
(
response
);
qa_conceal
(
document
.
getElementById
(
'p'
+
p
[
1
]),
'admin'
);
else
if
(
lines
[
0
]
==
'0'
)
{
if
(
response
.
result
===
'error'
&&
response
.
error
.
severity
===
'fatal'
)
{
alert
(
lines
[
1
]);
alert
(
response
.
error
.
message
);
qa_hide_waiting
(
target
);
}
else
qa_ajax_error
();
}
}
qa_hide_waiting
(
target
);
},
1
);
);
qa_show_waiting_after
(
target
,
false
);
qa_show_waiting_after
(
target
,
false
);
...
...
qa-content/qa-global.js
View file @
1b3b746f
...
@@ -152,11 +152,16 @@ function qa_favorite_click(elem)
...
@@ -152,11 +152,16 @@ function qa_favorite_click(elem)
return
false
;
return
false
;
}
}
function
qa_ajax_post
(
operation
,
params
,
callback
)
function
qa_ajax_post
(
operation
,
params
,
callback
,
version
)
{
{
$
.
extend
(
params
,
{
qa
:
'ajax'
,
qa_operation
:
operation
,
qa_root
:
qa_root
,
qa_request
:
qa_request
});
if
(
typeof
(
version
)
===
'undefined'
)
{
version
=
0
;
}
$
.
extend
(
params
,
{
qa
:
'ajax'
,
qa_operation
:
operation
,
qa_root
:
qa_root
,
qa_request
:
qa_request
,
version
:
version
});
$
.
post
(
qa_root
,
params
,
function
(
response
)
{
$
.
post
(
qa_root
,
params
,
function
(
response
)
{
if
(
version
===
0
)
{
var
header
=
'QA_AJAX_RESPONSE'
;
var
header
=
'QA_AJAX_RESPONSE'
;
var
headerpos
=
response
.
indexOf
(
header
);
var
headerpos
=
response
.
indexOf
(
header
);
...
@@ -164,10 +169,14 @@ function qa_ajax_post(operation, params, callback)
...
@@ -164,10 +169,14 @@ function qa_ajax_post(operation, params, callback)
callback
(
response
.
substr
(
headerpos
+
header
.
length
).
replace
(
/^
\s
+/
,
''
).
split
(
"
\
n"
));
callback
(
response
.
substr
(
headerpos
+
header
.
length
).
replace
(
/^
\s
+/
,
''
).
split
(
"
\
n"
));
else
else
callback
([]);
callback
([]);
}
else
{
},
'text'
).
fail
(
function
(
jqXHR
)
{
callback
(
response
);
}
},
version
===
0
?
'text'
:
'json'
).
fail
(
function
(
jqXHR
)
{
if
(
jqXHR
.
readyState
>
0
)
if
(
jqXHR
.
readyState
>
0
)
callback
([])
qa_ajax_error
();
});
});
}
}
...
...
qa-include/ajax/click-admin.php
View file @
1b3b746f
...
@@ -27,9 +27,15 @@ require_once QA_INCLUDE_DIR . 'app/cookies.php';
...
@@ -27,9 +27,15 @@ require_once QA_INCLUDE_DIR . 'app/cookies.php';
$entityid
=
qa_post_text
(
'entityid'
);
$entityid
=
qa_post_text
(
'entityid'
);
$action
=
qa_post_text
(
'action'
);
$action
=
qa_post_text
(
'action'
);
if
(
!
qa_check_form_security_code
(
'admin/click'
,
qa_post_text
(
'code'
)))
if
(
!
qa_check_form_security_code
(
'admin/click'
,
qa_post_text
(
'code'
)))
{
echo
"QA_AJAX_RESPONSE
\n
0
\n
"
.
qa_lang
(
'misc/form_security_reload'
);
$response
=
array
(
elseif
(
qa_admin_single_click
(
$entityid
,
$action
))
// permission check happens in here
'result'
=>
'error'
,
echo
"QA_AJAX_RESPONSE
\n
1
\n
"
;
'error'
=>
array
(
else
'message'
=>
qa_lang
(
'misc/form_security_reload'
),
echo
"QA_AJAX_RESPONSE
\n
0
\n
"
.
qa_lang
(
'main/general_error'
);
),
);
}
else
{
$response
=
qa_admin_single_click_array
(
$entityid
,
$action
);
}
echo
json_encode
(
$response
);
qa-include/app/admin.php
View file @
1b3b746f
...
@@ -374,35 +374,37 @@ function qa_admin_sub_navigation()
...
@@ -374,35 +374,37 @@ function qa_admin_sub_navigation()
}
}
if
(
!
qa_user_maximum_permit_error
(
'permit_moderate'
))
{
if
(
!
qa_user_maximum_permit_error
(
'permit_moderate'
))
{
$count
=
qa_user_permit_error
(
'permit_moderate'
)
?
null
:
qa_opt
(
'cache_queuedcount'
);
// if only in some categories don't show cached count
$count
=
qa_user_permit_error
(
'permit_moderate'
)
?
0
:
(
int
)
qa_opt
(
'cache_queuedcount'
);
// if only in some categories don't show cached count
$navigation
[
'admin/moderate'
]
=
array
(
$navigation
[
'admin/moderate'
]
=
array
(
'label'
=>
qa_lang_html
(
'admin/moderate_title'
)
.
(
$count
?
(
' ('
.
$count
.
')'
)
:
'
'
),
'label'
=>
qa_lang_html
_sub
(
'admin/moderate_title'
,
'<span class="qa-nav-sub-counter-moderate">'
.
qa_html
(
qa_format_number
(
$count
))
.
'</span>
'
),
'url'
=>
qa_path_html
(
'admin/moderate'
),
'url'
=>
qa_path_html
(
'admin/moderate'
),
);
);
}
}
if
(
qa_opt
(
'flagging_of_posts'
)
&&
!
qa_user_maximum_permit_error
(
'permit_hide_show'
))
{
if
(
qa_opt
(
'flagging_of_posts'
)
&&
!
qa_user_maximum_permit_error
(
'permit_hide_show'
))
{
$count
=
qa_user_permit_error
(
'permit_hide_show'
)
?
null
:
qa_opt
(
'cache_flaggedcount'
);
// if only in some categories don't show cached count
$count
=
qa_user_permit_error
(
'permit_hide_show'
)
?
0
:
(
int
)
qa_opt
(
'cache_flaggedcount'
);
// if only in some categories don't show cached count
$navigation
[
'admin/flagged'
]
=
array
(
$navigation
[
'admin/flagged'
]
=
array
(
'label'
=>
qa_lang_html
(
'admin/flagged_title'
)
.
(
$count
?
(
' ('
.
$count
.
')'
)
:
'
'
),
'label'
=>
qa_lang_html
_sub
(
'admin/flagged_title'
,
'<span class="qa-nav-sub-counter-flagged">'
.
qa_html
(
qa_format_number
(
$count
))
.
'</span>
'
),
'url'
=>
qa_path_html
(
'admin/flagged'
),
'url'
=>
qa_path_html
(
'admin/flagged'
),
);
);
}
}
if
(
!
qa_user_maximum_permit_error
(
'permit_hide_show'
)
||
!
qa_user_maximum_permit_error
(
'permit_delete_hidden'
))
{
if
(
!
qa_user_maximum_permit_error
(
'permit_hide_show'
)
||
!
qa_user_maximum_permit_error
(
'permit_delete_hidden'
))
{
$count
=
qa_user_permit_error
(
'permit_hide_show'
)
?
0
:
(
int
)
qa_opt
(
'cache_hiddencount'
);
$navigation
[
'admin/hidden'
]
=
array
(
$navigation
[
'admin/hidden'
]
=
array
(
'label'
=>
qa_lang_html
(
'admin/hidden_title
'
),
'label'
=>
qa_lang_html
_sub
(
'admin/hidden_title'
,
'<span class="qa-nav-sub-counter-hidden">'
.
qa_html
(
qa_format_number
(
$count
))
.
'</span>
'
),
'url'
=>
qa_path_html
(
'admin/hidden'
),
'url'
=>
qa_path_html
(
'admin/hidden'
),
);
);
}
}
if
(
!
QA_FINAL_EXTERNAL_USERS
&&
qa_opt
(
'moderate_users'
)
&&
$level
>=
QA_USER_LEVEL_MODERATOR
)
{
if
(
!
QA_FINAL_EXTERNAL_USERS
&&
qa_opt
(
'moderate_users'
)
&&
$level
>=
QA_USER_LEVEL_MODERATOR
)
{
$count
=
qa_opt
(
'cache_uapprovecount'
);
$count
=
(
int
)
qa_opt
(
'cache_uapprovecount'
);
$navigation
[
'admin/approve'
]
=
array
(
$navigation
[
'admin/approve'
]
=
array
(
'label'
=>
qa_lang_html
(
'admin/approve_users_title'
)
.
(
$count
?
(
' ('
.
$count
.
')'
)
:
'
'
),
'label'
=>
qa_lang_html
_sub
(
'admin/approve_users_title'
,
'<span class="qa-nav-sub-counter-approve">'
.
qa_html
(
qa_format_number
(
$count
))
.
'</span>
'
),
'url'
=>
qa_path_html
(
'admin/approve'
),
'url'
=>
qa_path_html
(
'admin/approve'
),
);
);
}
}
...
@@ -582,6 +584,257 @@ function qa_admin_single_click($entityid, $action)
...
@@ -582,6 +584,257 @@ function qa_admin_single_click($entityid, $action)
/**
/**
* Returns true if admin (hidden/flagged/approve/moderate) page $action performed on $entityid is permitted by the
* logged in user and was processed successfully
* @param $entityid
* @param $action
* @return array
*/
function
qa_admin_single_click_array
(
$entityid
,
$action
)
{
$userid
=
qa_get_logged_in_userid
();
$response
=
array
();
if
(
!
QA_FINAL_EXTERNAL_USERS
&&
(
$action
===
'userapprove'
||
$action
===
'userblock'
))
{
// approve/block moderated users
require_once
QA_INCLUDE_DIR
.
'db/selects.php'
;
$useraccount
=
qa_db_select_with_pending
(
qa_db_user_account_selectspec
(
$entityid
,
true
));
if
(
isset
(
$useraccount
)
&&
qa_get_logged_in_level
()
>=
QA_USER_LEVEL_MODERATOR
)
{
switch
(
$action
)
{
case
'userapprove'
:
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'
);
}
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
[
'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
;
case
'userblock'
:
require_once
QA_INCLUDE_DIR
.
'app/users-edit.php'
;
qa_set_user_blocked
(
$useraccount
[
'userid'
],
$useraccount
[
'handle'
],
true
);
$response
[
'result'
]
=
'success'
;
$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
:
}
}
}
else
{
// something to do with a post
require_once
QA_INCLUDE_DIR
.
'app/posts.php'
;
$post
=
qa_db_single_select
(
qa_db_full_post_selectspec
(
null
,
$entityid
));
// Handle non-existent posts
if
(
$post
===
null
)
{
switch
(
$action
)
{
case
'approve'
:
case
'reject'
:
$entityCount
=
(
int
)
qa_opt
(
'cache_queuedcount'
);
$selector
=
'.qa-nav-sub-counter-moderate'
;
break
;
case
'reshow'
:
case
'delete'
:
$entityCount
=
(
int
)
qa_opt
(
'cache_hiddencount'
);
$selector
=
'.qa-nav-sub-counter-hidden'
;
break
;
case
'hide'
:
case
'clearflags'
:
$entityCount
=
(
int
)
qa_opt
(
'cache_flaggedcount'
);
$selector
=
'.qa-nav-sub-counter-flagged'
;
break
;
default
:
$selector
=
''
;
$entityCount
=
0
;
}
return
array
(
'result'
=>
'error'
,
'error'
=>
array
(
'type'
=>
'post-not-found'
,
'message'
=>
qa_lang_html
(
'main/general_error'
),
),
'domUpdates'
=>
array
(
array
(
'selector'
=>
$selector
,
'html'
=>
$entityCount
,
),
array
(
'selector'
=>
'#p'
.
$entityid
,
'action'
=>
'conceal'
,
),
),
);
}
$queued
=
(
substr
(
$post
[
'type'
],
1
)
==
'_QUEUED'
);
switch
(
$action
)
{
case
'approve'
:
case
'reject'
:
$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
[
'domUpdates'
]
=
array
(
array
(
'selector'
=>
'.qa-nav-sub-counter-moderate'
,
'html'
=>
$entityCount
,
),
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
[
'error'
][
'severity'
]
=
'fatal'
;
}
else
{
$postStatus
=
$action
===
'approve'
?
QA_POST_STATUS_NORMAL
:
QA_POST_STATUS_HIDDEN
;
// 'reject'
qa_post_set_status
(
$entityid
,
$postStatus
,
$userid
);
$response
[
'result'
]
=
'success'
;
$response
[
'domUpdates'
]
=
array
(
array
(
'selector'
=>
'.qa-nav-sub-counter-moderate'
,
'html'
=>
max
(
$entityCount
-
1
,
0
),
),
array
(
'selector'
=>
'#p'
.
$entityid
,
'action'
=>
'conceal'
,
),
);
}
break
;
case
'reshow'
:
case
'delete'
:
$entityCount
=
(
int
)
qa_opt
(
'cache_hiddencount'
);
if
(
!
$post
[
'hidden'
])
{
$response
[
'result'
]
=
'error'
;
$response
[
'error'
][
'type'
]
=
'post-not-hidden'
;
$response
[
'error'
][
'message'
]
=
qa_lang_html
(
'main/general_error'
);
$response
[
'domUpdates'
]
=
array
(
array
(
'selector'
=>
'.qa-nav-sub-counter-hidden'
,
'html'
=>
$entityCount
,
),
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
[
'error'
][
'severity'
]
=
'fatal'
;
}
else
{
if
(
$action
===
'reshow'
)
{
qa_post_set_status
(
$entityid
,
QA_POST_STATUS_NORMAL
,
$userid
);
}
else
{
// 'delete'
qa_post_delete
(
$entityid
);
}
$response
[
'result'
]
=
'success'
;
$response
[
'domUpdates'
]
=
array
(
array
(
'selector'
=>
'.qa-nav-sub-counter-hidden'
,
'html'
=>
max
(
$entityCount
-
1
,
0
),
),
array
(
'selector'
=>
'#p'
.
$entityid
,
'action'
=>
'conceal'
,
),
);
}
break
;
case
'hide'
:
case
'clearflags'
:
$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
[
'domUpdates'
]
=
array
(
array
(
'selector'
=>
'.qa-nav-sub-counter-flagged'
,
'html'
=>
$entityCount
,
),
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
[
'error'
][
'severity'
]
=
'fatal'
;
}
else
{
if
(
$action
===
'hide'
)
{
qa_post_set_status
(
$entityid
,
QA_POST_STATUS_HIDDEN
,
$userid
);
}
else
{
// 'clearflags'
require_once
QA_INCLUDE_DIR
.
'app/votes.php'
;
qa_flags_clear_all
(
$post
,
$userid
,
qa_get_logged_in_handle
(),
null
);
}
$response
[
'result'
]
=
'success'
;
$response
[
'domUpdates'
]
=
array
(
array
(
'selector'
=>
'.qa-nav-sub-counter-flagged'
,
'html'
=>
max
(
$entityCount
-
1
,
0
),
),
array
(
'selector'
=>
'#p'
.
$entityid
,
'action'
=>
'conceal'
,
),
);
}
break
;
default
:
}
}
return
$response
;
}
/**
* Checks for a POSTed click on an admin (hidden/flagged/approve/moderate) page, and refresh the page if processed successfully (non Ajax)
* Checks for a POSTed click on an admin (hidden/flagged/approve/moderate) page, and refresh the page if processed successfully (non Ajax)
*/
*/
function
qa_admin_check_clicks
()
function
qa_admin_check_clicks
()
...
...
qa-include/app/post-update.php
View file @
1b3b746f
...
@@ -374,6 +374,10 @@ function qa_question_set_status($oldquestion, $status, $userid, $handle, $cookie
...
@@ -374,6 +374,10 @@ function qa_question_set_status($oldquestion, $status, $userid, $handle, $cookie
if
(
$wasqueued
||
(
$status
==
QA_POST_STATUS_QUEUED
))
if
(
$wasqueued
||
(
$status
==
QA_POST_STATUS_QUEUED
))
qa_db_queuedcount_update
();
qa_db_queuedcount_update
();
if
(
$event
===
'q_hide'
||
$event
===
'q_reshow'
)
{
qa_db_hiddencount_update
();
}
if
(
$oldquestion
[
'flagcount'
])
if
(
$oldquestion
[
'flagcount'
])
qa_db_flaggedcount_update
();
qa_db_flaggedcount_update
();
...
@@ -536,6 +540,7 @@ function qa_question_delete($oldquestion, $userid, $handle, $cookieid, $oldclose
...
@@ -536,6 +540,7 @@ function qa_question_delete($oldquestion, $userid, $handle, $cookieid, $oldclose
qa_db_post_delete
(
$oldquestion
[
'postid'
]);
// also deletes any related voteds due to foreign key cascading
qa_db_post_delete
(
$oldquestion
[
'postid'
]);
// also deletes any related voteds due to foreign key cascading
qa_update_counts_for_q
(
null
);
qa_update_counts_for_q
(
null
);
qa_db_category_path_qcount_update
(
$oldpath
);
// don't do inside qa_update_counts_for_q() since post no longer exists
qa_db_category_path_qcount_update
(
$oldpath
);
// don't do inside qa_update_counts_for_q() since post no longer exists
qa_db_hiddencount_update
();
qa_db_points_update_ifuser
(
$oldquestion
[
'userid'
],
array
(
'qposts'
,
'aselects'
,
'qvoteds'
,
'upvoteds'
,
'downvoteds'
));
qa_db_points_update_ifuser
(
$oldquestion
[
'userid'
],
array
(
'qposts'
,
'aselects'
,
'qvoteds'
,
'upvoteds'
,
'downvoteds'
));
foreach
(
$useridvotes
as
$voteruserid
=>
$vote
)
{
foreach
(
$useridvotes
as
$voteruserid
=>
$vote
)
{
...
@@ -764,6 +769,10 @@ function qa_answer_set_status($oldanswer, $status, $userid, $handle, $cookieid,
...
@@ -764,6 +769,10 @@ function qa_answer_set_status($oldanswer, $status, $userid, $handle, $cookieid,
if
(
$wasqueued
||
$status
==
QA_POST_STATUS_QUEUED
)
if
(
$wasqueued
||
$status
==
QA_POST_STATUS_QUEUED
)
qa_db_queuedcount_update
();
qa_db_queuedcount_update
();
if
(
$event
===
'a_hide'
||
$event
===
'a_reshow'
)
{
qa_db_hiddencount_update
();
}
if
(
$oldanswer
[
'flagcount'
])
if
(
$oldanswer
[
'flagcount'
])
qa_db_flaggedcount_update
();
qa_db_flaggedcount_update
();
...
@@ -846,6 +855,7 @@ function qa_answer_delete($oldanswer, $question, $userid, $handle, $cookieid)
...
@@ -846,6 +855,7 @@ function qa_answer_delete($oldanswer, $question, $userid, $handle, $cookieid)
}
}
qa_update_q_counts_for_a
(
$question
[
'postid'
]);
qa_update_q_counts_for_a
(
$question
[
'postid'
]);
qa_db_hiddencount_update
();
qa_db_points_update_ifuser
(
$oldanswer
[
'userid'
],
array
(
'aposts'
,
'aselecteds'
,
'avoteds'
,
'upvoteds'
,
'downvoteds'
));
qa_db_points_update_ifuser
(
$oldanswer
[
'userid'
],
array
(
'aposts'
,
'aselecteds'
,
'avoteds'
,
'upvoteds'
,
'downvoteds'
));
foreach
(
$useridvotes
as
$voteruserid
=>
$vote
)
{
foreach
(
$useridvotes
as
$voteruserid
=>
$vote
)
{
...
@@ -1151,6 +1161,10 @@ function qa_comment_set_status($oldcomment, $status, $userid, $handle, $cookieid
...
@@ -1151,6 +1161,10 @@ function qa_comment_set_status($oldcomment, $status, $userid, $handle, $cookieid
if
(
$wasqueued
||
$status
==
QA_POST_STATUS_QUEUED
)
if
(
$wasqueued
||
$status
==
QA_POST_STATUS_QUEUED
)
qa_db_queuedcount_update
();
qa_db_queuedcount_update
();
if
(
$event
===
'c_hide'
||
$event
===
'c_reshow'
)
{
qa_db_hiddencount_update
();
}
if
(
$oldcomment
[
'flagcount'
])
if
(
$oldcomment
[
'flagcount'
])
qa_db_flaggedcount_update
();
qa_db_flaggedcount_update
();
...
@@ -1234,6 +1248,7 @@ function qa_comment_delete($oldcomment, $question, $parent, $userid, $handle, $c
...
@@ -1234,6 +1248,7 @@ function qa_comment_delete($oldcomment, $question, $parent, $userid, $handle, $c
qa_post_unindex
(
$oldcomment
[
'postid'
]);
qa_post_unindex
(
$oldcomment
[
'postid'
]);
qa_db_post_delete
(
$oldcomment
[
'postid'
]);
qa_db_post_delete
(
$oldcomment
[
'postid'
]);
qa_db_hiddencount_update
();
qa_db_points_update_ifuser
(
$oldcomment
[
'userid'
],
array
(
'cposts'
));
qa_db_points_update_ifuser
(
$oldcomment
[
'userid'
],
array
(
'cposts'
));
qa_db_ccount_update
();
qa_db_ccount_update
();
...
...
qa-include/db/post-create.php
View file @
1b3b746f
...
@@ -453,3 +453,19 @@ function qa_db_queuedcount_update()
...
@@ -453,3 +453,19 @@ function qa_db_queuedcount_update()
);
);
}
}
}
}
/**
* Update the cached count in the database of the number of posts which are hidden
*/
function
qa_db_hiddencount_update
()
{
if
(
qa_should_update_counts
())
{
qa_db_query_sub
(
"INSERT INTO ^options (title, content) "
.
"SELECT 'cache_hiddencount', COUNT(*) FROM ^posts "
.
"WHERE type IN ('Q_HIDDEN', 'A_HIDDEN', 'C_HIDDEN') "
.
"ON DUPLICATE KEY UPDATE content = VALUES(content)"
);
}
}
qa-include/lang/qa-lang-admin.php
View file @
1b3b746f
...
@@ -37,7 +37,7 @@ return array(
...
@@ -37,7 +37,7 @@ return array(
'after_x'
=>
'After "^"'
,
'after_x'
=>
'After "^"'
,
'after_x_tab'
=>
'After "^" tab'
,
'after_x_tab'
=>
'After "^" tab'
,
'approve_user_popup'
=>
'Approve user'
,
'approve_user_popup'
=>
'Approve user'
,
'approve_users_title'
=>
'Approve users'
,
'approve_users_title'
=>
'Approve users
(^)
'
,
'basic_editor'
=>
'Basic Editor'
,
'basic_editor'
=>
'Basic Editor'
,
'before_main_menu'
=>
'Before tabs at top'
,
'before_main_menu'
=>
'Before tabs at top'
,
'blobs_directory_error'
=>
'The directory ^ defined as QA_BLOBS_DIRECTORY is not writable by the web server.'
,
'blobs_directory_error'
=>
'The directory ^ defined as QA_BLOBS_DIRECTORY is not writable by the web server.'
,
...
@@ -121,7 +121,7 @@ return array(
...
@@ -121,7 +121,7 @@ return array(
'field_single_line'
=>
'Single line of text'
,
'field_single_line'
=>
'Single line of text'
,
'field_type'
=>
'Content type:'
,
'field_type'
=>
'Content type:'
,
'first'
=>
'First'
,
'first'
=>
'First'
,
'flagged_title'
=>
'Flagged'
,
'flagged_title'
=>
'Flagged
(^)
'
,
'form_security_expired'
=>
'Form security code expired - please try again'
,
'form_security_expired'
=>
'Form security code expired - please try again'
,
'from_anon'
=>
'From anonymous:'
,
'from_anon'
=>
'From anonymous:'
,
'from_users'
=>
'From users:'
,
'from_users'
=>
'From users:'
,
...
@@ -129,7 +129,7 @@ return array(
...
@@ -129,7 +129,7 @@ return array(
'hidden_answers_deleted'
=>
'Deleted ^1 of ^2 hidden answers without dependents...'
,
'hidden_answers_deleted'
=>
'Deleted ^1 of ^2 hidden answers without dependents...'
,
'hidden_comments_deleted'
=>
'Deleted ^1 of ^2 hidden comments...'
,
'hidden_comments_deleted'
=>
'Deleted ^1 of ^2 hidden comments...'
,
'hidden_questions_deleted'
=>
'Deleted ^1 of ^2 hidden questions without dependents...'
,
'hidden_questions_deleted'
=>
'Deleted ^1 of ^2 hidden questions without dependents...'
,
'hidden_title'
=>
'Hidden'
,
'hidden_title'
=>
'Hidden
(^)
'
,
'hotness_factors'
=>
'Relative importance for question hotness:'
,
'hotness_factors'
=>
'Relative importance for question hotness:'
,
'ip_address_pages'
=>
'IP address pages'
,
'ip_address_pages'
=>
'IP address pages'
,
'layout_title'
=>
'Layout'
,
'layout_title'
=>
'Layout'
,
...
@@ -145,7 +145,7 @@ return array(
...
@@ -145,7 +145,7 @@ return array(
'maintenance_admin_only'
=>
'Your site is in ^1maintenance^2 and is currently inaccessible to regular users.'
,
'maintenance_admin_only'
=>
'Your site is in ^1maintenance^2 and is currently inaccessible to regular users.'
,
'maximum_x'
=>
' (max ^)'
,
'maximum_x'
=>
' (max ^)'
,
'memcached_error'
=>
'Memcached error: ^'
,
'memcached_error'
=>
'Memcached error: ^'
,
'moderate_title'
=>
'Moderate'
,
'moderate_title'
=>
'Moderate
(^)
'
,
'module_x_database_init'
=>
'The ^1 ^2 module requires some ^3database initialization^4.'
,
'module_x_database_init'
=>
'The ^1 ^2 module requires some ^3database initialization^4.'
,
'most_flagged_title'
=>
'Flagged content'
,
'most_flagged_title'
=>
'Flagged content'
,
'mysql_version'
=>
'MySQL version:'
,
'mysql_version'
=>
'MySQL version:'
,
...
@@ -215,6 +215,7 @@ return array(
...
@@ -215,6 +215,7 @@ return array(
'recalc_stop'
=>
'Stop recalculating'
,
'recalc_stop'
=>
'Stop recalculating'
,
'recent_approve_title'
=>
'Recent content waiting for approval'
,
'recent_approve_title'
=>
'Recent content waiting for approval'
,
'recent_hidden_title'
=>
'Recent hidden content'
,
'recent_hidden_title'
=>
'Recent hidden content'
,
'recent_users_title'
=>
'Recent users waiting for approval'
,
'recount_posts'
=>
'Recount posts'
,
'recount_posts'
=>
'Recount posts'
,
'recount_posts_as_recounted'
=>
'Recounted answers and hotness for ^1 of ^2 posts...'
,
'recount_posts_as_recounted'
=>
'Recounted answers and hotness for ^1 of ^2 posts...'
,
'recount_posts_complete'
=>
'All posts were successfully recounted.'
,
'recount_posts_complete'
=>
'All posts were successfully recounted.'
,
...
...
qa-include/pages/admin/admin-approve.php
View file @
1b3b746f
...
@@ -60,7 +60,7 @@ $pageerror = qa_admin_check_clicks();
...
@@ -60,7 +60,7 @@ $pageerror = qa_admin_check_clicks();
$qa_content
=
qa_content_prepare
();
$qa_content
=
qa_content_prepare
();
$qa_content
[
'title'
]
=
qa_lang_html
(
'admin/
approve
_users_title'
);
$qa_content
[
'title'
]
=
qa_lang_html
(
'admin/
recent
_users_title'
);
$qa_content
[
'error'
]
=
isset
(
$pageerror
)
?
$pageerror
:
qa_admin_page_error
();
$qa_content
[
'error'
]
=
isset
(
$pageerror
)
?
$pageerror
:
qa_admin_page_error
();
$qa_content
[
'message_list'
]
=
array
(
$qa_content
[
'message_list'
]
=
array
(
...
...
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