Skip to content
Permalink
Browse files

Fixes #1338

  • Loading branch information...
bloatware committed Sep 8, 2018
1 parent 5adebd0 commit 18f4b29b69dc59d3c0215ee089ebd2c7df7e55fe
@@ -589,9 +589,15 @@ function discuss_multi_edit()
// FIXME: this method needs some refactoring.
$selected = ps('selected');
$method = ps('edit_method');
$done = array();
$visStates = array(
'delete' => false,
'spam' => SPAM,
'unmoderated' => MODERATE,
'visible' => VISIBLE,
);
$visState = isset($visStates[$method]) ? $visStates[$method] : null;
if ($selected && is_array($selected)) {
if ($selected && is_array($selected) && isset($visState)) {
// Get all articles for which we have to update the count.
$ids = array();
@@ -601,16 +607,11 @@ function discuss_multi_edit()
// Remove bogus (false) entries to prevent SQL syntax errors being thrown.
$ids = array_filter($ids);
$done = array();
if ($ids) {
$idList = implode(',', $ids);
$visStates = array(
'spam' => SPAM,
'unmoderated' => MODERATE,
'visible' => VISIBLE,
);
$parentids = safe_column("DISTINCT parentid", 'txp_discuss', "discussid IN (".$idList.")");
$parentids = array();
$rs = safe_rows_start("*", 'txp_discuss', "discussid IN (".$idList.")");
@@ -625,35 +626,33 @@ function discuss_multi_edit()
if (safe_delete('txp_discuss', "discussid = '$id'")) {
$done[] = $id;
}
callback_event('discuss_deleted', '', 0, $done);
} else {
$visState = (isset($visStates[$method])) ? $visStates[$method] : null;
if ($visState !== null && safe_update('txp_discuss',
} elseif (safe_update('txp_discuss',
"visible = ".$visState,
"discussid = '$id'"
)) {
$done[] = $id;
}
)) {
$done[] = $id;
}
}
}
$doneStr = join(', ', $done);
if ($doneStr) {
if ($done) {
// Might as well clean up all comment counts while we're here.
clean_comment_counts($parentids);
$doneStr = join(', ', $done);
$messages = array(
'delete' => gTxt('comments_deleted', array('{list}' => $doneStr)),
'spam' => gTxt('comments_marked_spam', array('{list}' => $doneStr)),
'unmoderated' => gTxt('comments_marked_unmoderated', array('{list}' => $doneStr)),
'visible' => gTxt('comments_marked_visible', array('{list}' => $doneStr)),
);
update_lastmod('discuss_updated', $done);
if ($method == 'delete') {
callback_event('discuss_deleted', '', 0, $done);
}
update_lastmod($method == 'delete' ? 'discuss_deleted' : 'discuss_updated', $done);
return discuss_list($messages[$method]);
}
@@ -605,9 +605,9 @@ function list_multi_edit()
}
if ($selected && safe_delete('textpattern', "ID IN (".join(',', $selected).")")) {
safe_update('txp_discuss', "visible = ".MODERATE, "parentid IN (".join(',', $selected).")");
callback_event('articles_deleted', '', 0, $selected);
callback_event('multi_edited.articles', 'delete', 0, compact('selected', 'field', 'value'));
safe_delete('txp_discuss', "parentid IN (".join(',', $selected).")");
update_lastmod('articles_deleted', $selected);
now('posted', true);
now('expires', true);
@@ -2240,9 +2240,9 @@ function sanitizeForUrl($text, $strip = '/[^\p{L}\p{N}\-_\s\/\\\\]/u')
return $out;
}
// Remove names entities and tags.
// Remove named entities and tags.
$text = preg_replace("/(^|&\S+;)|(<[^>]*>)/U", "", dumbDown($text));
// Remove all characters except letter, number, some emoji, dash, space and backslash
// Remove all characters except letter, number, dash, space and backslash
$text = preg_replace($strip, '', $text);
// Collapse spaces, minuses, (back-)slashes.
$text = trim(preg_replace('/[\s\-\/\\\\]+/', '-', $text), '-');
@@ -356,12 +356,10 @@ function parse($thing, $condition = true)
$pattern = $short_tags ? 'txp|[a-z]+:' : 'txp:?';
}
if (!$short_tags) {
if (false === strpos($thing, '<txp:')) {
return $condition ? $thing : ($thing ? '' : '1');
}
} elseif (!preg_match("@<(?:{$pattern}):@", $thing)) {
return $condition ? $thing : ($thing ? '' : '1');
if (!$short_tags && false === strpos($thing, '<txp:') ||
$short_tags && !preg_match("@<(?:{$pattern}):@", $thing))
{
return $condition ? $thing : ($thing !== null ? '' : '1');
}
$hash = sha1($thing);
@@ -450,7 +448,7 @@ function parse($thing, $condition = true)
$tag = $txp_parsed[$hash];
if (empty($tag)) {
return $condition ? $thing : ($thing ? '' : '1');
return $condition ? $thing : ($thing !== null ? '' : '1');
}
list($first, $last) = $txp_else[$hash];
@@ -586,6 +586,8 @@ function textpattern()
if ($html === false) {
txp_die(gTxt('unknown_section'), '404');
} else {
$html = trim($html);
}
// Make sure the page has an article tag if necessary.

0 comments on commit 18f4b29

Please sign in to comment.
You can’t perform that action at this time.