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
b74d7099
Commit
b74d7099
authored
Aug 17, 2018
by
pupi1985
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create cache_hiddencount setting and display the count in the admin menu
parent
5baf8603
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
21 deletions
+50
-21
click-admin.php
qa-include/ajax/click-admin.php
+4
-17
admin.php
qa-include/app/admin.php
+14
-3
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
+1
-1
No files found.
qa-include/ajax/click-admin.php
View file @
b74d7099
...
...
@@ -26,29 +26,16 @@ require_once QA_INCLUDE_DIR . 'app/cookies.php';
$entityid
=
qa_post_text
(
'entityid'
);
$action
=
qa_post_text
(
'action'
);
$version
=
(
int
)
qa_post_text
(
'version'
);
switch
(
$version
)
{
case
1
:
if
(
!
qa_check_form_security_code
(
'admin/click'
,
qa_post_text
(
'code'
)))
{
if
(
!
qa_check_form_security_code
(
'admin/click'
,
qa_post_text
(
'code'
)))
{
$response
=
array
(
'result'
=>
'error'
,
'error'
=>
array
(
'message'
=>
qa_lang
(
'misc/form_security_reload'
),
),
);
}
else
{
}
else
{
$response
=
qa_admin_single_click_array
(
$entityid
,
$action
);
}
echo
json_encode
(
$response
);
break
;
default
:
// prior version
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'
);
elseif
(
qa_admin_single_click
(
$entityid
,
$action
))
echo
"QA_AJAX_RESPONSE
\n
1
\n
"
;
else
echo
"QA_AJAX_RESPONSE
\n
0
\n
"
.
qa_lang
(
'main/general_error'
);
}
echo
json_encode
(
$response
);
qa-include/app/admin.php
View file @
b74d7099
...
...
@@ -392,8 +392,10 @@ function qa_admin_sub_navigation()
}
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
(
'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'
),
);
}
...
...
@@ -663,7 +665,7 @@ function qa_admin_single_click_array($entityid, $action)
$response
[
'domUpdates'
]
=
array
(
array
(
'selector'
=>
'.qa-nav-sub-counter-moderate'
,
'html'
=>
max
(
$entityCount
-
1
,
0
),
'html'
=>
max
(
$entityCount
,
0
),
),
array
(
'selector'
=>
'#p'
.
$entityid
,
...
...
@@ -697,12 +699,17 @@ function qa_admin_single_click_array($entityid, $action)
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'
=>
max
(
$entityCount
,
0
),
),
array
(
'selector'
=>
'#p'
.
$entityid
,
'action'
=>
'conceal'
,
),
...
...
@@ -722,6 +729,10 @@ function qa_admin_single_click_array($entityid, $action)
$response
[
'result'
]
=
'success'
;
$response
[
'domUpdates'
]
=
array
(
array
(
'selector'
=>
'.qa-nav-sub-counter-hidden'
,
'html'
=>
max
(
$entityCount
-
1
,
0
),
),
array
(
'selector'
=>
'#p'
.
$entityid
,
'action'
=>
'conceal'
,
),
...
...
@@ -739,7 +750,7 @@ function qa_admin_single_click_array($entityid, $action)
$response
[
'domUpdates'
]
=
array
(
array
(
'selector'
=>
'.qa-nav-sub-counter-flagged'
,
'html'
=>
max
(
$entityCount
-
1
,
0
),
'html'
=>
max
(
$entityCount
,
0
),
),
array
(
'selector'
=>
'#p'
.
$entityid
,
...
...
qa-include/app/post-update.php
View file @
b74d7099
...
...
@@ -374,6 +374,10 @@ function qa_question_set_status($oldquestion, $status, $userid, $handle, $cookie
if
(
$wasqueued
||
(
$status
==
QA_POST_STATUS_QUEUED
))
qa_db_queuedcount_update
();
if
(
$event
===
'q_hide'
||
$event
===
'q_reshow'
)
{
qa_db_hiddencount_update
();
}
if
(
$oldquestion
[
'flagcount'
])
qa_db_flaggedcount_update
();
...
...
@@ -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_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_hiddencount_update
();
qa_db_points_update_ifuser
(
$oldquestion
[
'userid'
],
array
(
'qposts'
,
'aselects'
,
'qvoteds'
,
'upvoteds'
,
'downvoteds'
));
foreach
(
$useridvotes
as
$voteruserid
=>
$vote
)
{
...
...
@@ -764,6 +769,10 @@ function qa_answer_set_status($oldanswer, $status, $userid, $handle, $cookieid,
if
(
$wasqueued
||
$status
==
QA_POST_STATUS_QUEUED
)
qa_db_queuedcount_update
();
if
(
$event
===
'a_hide'
||
$event
===
'a_reshow'
)
{
qa_db_hiddencount_update
();
}
if
(
$oldanswer
[
'flagcount'
])
qa_db_flaggedcount_update
();
...
...
@@ -846,6 +855,7 @@ function qa_answer_delete($oldanswer, $question, $userid, $handle, $cookieid)
}
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'
));
foreach
(
$useridvotes
as
$voteruserid
=>
$vote
)
{
...
...
@@ -1151,6 +1161,10 @@ function qa_comment_set_status($oldcomment, $status, $userid, $handle, $cookieid
if
(
$wasqueued
||
$status
==
QA_POST_STATUS_QUEUED
)
qa_db_queuedcount_update
();
if
(
$event
===
'c_hide'
||
$event
===
'c_reshow'
)
{
qa_db_hiddencount_update
();
}
if
(
$oldcomment
[
'flagcount'
])
qa_db_flaggedcount_update
();
...
...
@@ -1234,6 +1248,7 @@ function qa_comment_delete($oldcomment, $question, $parent, $userid, $handle, $c
qa_post_unindex
(
$oldcomment
[
'postid'
]);
qa_db_post_delete
(
$oldcomment
[
'postid'
]);
qa_db_hiddencount_update
();
qa_db_points_update_ifuser
(
$oldcomment
[
'userid'
],
array
(
'cposts'
));
qa_db_ccount_update
();
...
...
qa-include/db/post-create.php
View file @
b74d7099
...
...
@@ -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 @
b74d7099
...
...
@@ -129,7 +129,7 @@ return array(
'hidden_answers_deleted'
=>
'Deleted ^1 of ^2 hidden answers without dependents...'
,
'hidden_comments_deleted'
=>
'Deleted ^1 of ^2 hidden comments...'
,
'hidden_questions_deleted'
=>
'Deleted ^1 of ^2 hidden questions without dependents...'
,
'hidden_title'
=>
'Hidden'
,
'hidden_title'
=>
'Hidden
(^)
'
,
'hotness_factors'
=>
'Relative importance for question hotness:'
,
'ip_address_pages'
=>
'IP address pages'
,
'layout_title'
=>
'Layout'
,
...
...
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