Skip to content
Snippets Groups Projects
Commit aef2b4af authored by David Siegfried's avatar David Siegfried Committed by Jan-Hendrik Willms
Browse files

cleanup showNews.inc.php, fixes #4001

Closes #4001

Merge request studip/studip!2850
parent b4f508cf
No related branches found
No related tags found
No related merge requests found
...@@ -25,51 +25,6 @@ ...@@ -25,51 +25,6 @@
require_once 'lib/object.inc.php'; require_once 'lib/object.inc.php';
/**
* generates proper text for confirmation question and deletes comments
*
*
* @param mixed $comment_id (single or array)
* @return string text for confirmation question or empty string after deletion
*/
function delete_comments($delete_comments_array = '')
{
$text = '';
$confirmed = false;
if (! is_array($delete_comments_array))
$delete_comments_array = [$delete_comments_array];
if (Request::submitted('yes') AND Request::isPost()) {
CSRFProtection::verifySecurityToken();
$confirmed = true;
}
if ($confirmed) {
foreach ($delete_comments_array as $comment_id) {
$delete_comment = new StudipComment($comment_id);
if (!$delete_comment->isNew()) {
if (!is_object($news[$delete_comment->getValue("object_id")]))
$news[$delete_comment->getValue("object_id")] = new StudipNews($delete_comment->getValue("object_id"));
// user has to have delete permission for news
if ($news[$delete_comment->getValue("object_id")]->havePermission('delete')) {
$delete_comment->delete();
$delete_counter++;
}
else
PageLayout::postMessage(MessageBox::error(_('Keine Berechtigung zum Löschen des Kommentars.')));
}
}
if ($delete_counter > 1)
PageLayout::postMessage(MessageBox::success(sprintf(_('%s Kommentare wurden gelöscht.'), $delete_counter)));
elseif ($delete_counter == 1)
PageLayout::postMessage(MessageBox::success(_('Kommentar wurde gelöscht.')));
} else {
if (count($delete_comments_array) > 1) {
$text = sprintf(_('Wollen Sie die %s Komentare jetzt löschen?'), count($delete_comments_array));
} elseif (count($delete_comments_array) == 1) {
$text = _('Wollen Sie den Kommentar jetzt löschen?');
}
}
return $text;
}
/** /**
* generates proper text for confirmation question and deletes news * generates proper text for confirmation question and deletes news
...@@ -89,6 +44,7 @@ function delete_news($delete_news_array) ...@@ -89,6 +44,7 @@ function delete_news($delete_news_array)
CSRFProtection::verifySecurityToken(); CSRFProtection::verifySecurityToken();
$confirmed = true; $confirmed = true;
} }
$delete_news_titles = [];
foreach ($delete_news_array as $news_id) { foreach ($delete_news_array as $news_id) {
if ($news_id) { if ($news_id) {
$delete_news = new StudipNews($news_id); $delete_news = new StudipNews($news_id);
...@@ -232,13 +188,15 @@ function remove_news($remove_array) ...@@ -232,13 +188,15 @@ function remove_news($remove_array)
/** /**
* *
* @param unknown_type $range_id * @param string $range_id
* @param unknown_type $type * @param string $type
*/ */
function show_rss_news($range_id, $type) function show_rss_news($range_id, $type)
{ {
$item_url_fmt = '%1$s&contentbox_open=%2$s#%2$s'; $item_url_fmt = '%1$s&contentbox_open=%2$s#%2$s';
$title = '';
$studip_url = '';
$description = '';
switch ($type){ switch ($type){
case 'user': case 'user':
$studip_url = $GLOBALS['ABSOLUTE_URI_STUDIP'] . 'dispatch.php/profile?again=yes&username=' . get_username($range_id); $studip_url = $GLOBALS['ABSOLUTE_URI_STUDIP'] . 'dispatch.php/profile?again=yes&username=' . get_username($range_id);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment