Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stud.IP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jan-Hendrik Willms
Stud.IP
Commits
aef2b4af
Commit
aef2b4af
authored
11 months ago
by
David Siegfried
Committed by
Jan-Hendrik Willms
11 months ago
Browse files
Options
Downloads
Patches
Plain Diff
cleanup showNews.inc.php, fixes #4001
Closes #4001 Merge request
studip/studip!2850
parent
b4f508cf
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/showNews.inc.php
+24
-66
24 additions, 66 deletions
lib/showNews.inc.php
with
24 additions
and
66 deletions
lib/showNews.inc.php
+
24
−
66
View file @
aef2b4af
...
...
@@ -25,51 +25,6 @@
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
...
...
@@ -89,6 +44,7 @@ function delete_news($delete_news_array)
CSRFProtection
::
verifySecurityToken
();
$confirmed
=
true
;
}
$delete_news_titles
=
[];
foreach
(
$delete_news_array
as
$news_id
)
{
if
(
$news_id
)
{
$delete_news
=
new
StudipNews
(
$news_id
);
...
...
@@ -103,10 +59,10 @@ function delete_news($delete_news_array)
if
(
$delete_news
->
getValue
(
'user_id'
)
!=
$GLOBALS
[
'auth'
]
->
auth
[
'uid'
])
{
setTempLanguage
(
$delete_news
->
getValue
(
'user_id'
));
$msg
=
sprintf
(
_
(
'Ihre Ankündigung "%s" wurde von der Administration gelöscht!.'
),
(
string
)
$delete_news
->
topic
,
get_fullname
()
.
' ('
.
get_username
()
.
')'
)
.
"
\n
"
;
_
(
'Ihre Ankündigung "%s" wurde von der Administration gelöscht!.'
),
(
string
)
$delete_news
->
topic
,
get_fullname
()
.
' ('
.
get_username
()
.
')'
)
.
"
\n
"
;
$msg_object
->
insert_message
(
$msg
,
get_username
(
$delete_news
->
user_id
),
...
...
@@ -132,15 +88,15 @@ function delete_news($delete_news_array)
if
(
!
$confirmed
)
{
if
(
count
(
$delete_news_titles
)
===
1
)
{
$text
=
sprintf
(
_
(
'- Die Ankündigung "%s" wird unwiderruflich gelöscht.'
),
$delete_news_titles
[
0
]
)
.
"
\n
"
;
_
(
'- Die Ankündigung "%s" wird unwiderruflich gelöscht.'
),
$delete_news_titles
[
0
]
)
.
"
\n
"
;
}
elseif
(
count
(
$delete_news_titles
)
>
1
)
{
$text
=
sprintf
(
_
(
'- Die %s Ankündigungen "%s" werden unwiderruflich gelöscht.'
),
count
(
$delete_news_titles
),
implode
(
'", "'
,
$delete_news_titles
)
)
.
"
\n
"
;
_
(
'- Die %s Ankündigungen "%s" werden unwiderruflich gelöscht.'
),
count
(
$delete_news_titles
),
implode
(
'", "'
,
$delete_news_titles
)
)
.
"
\n
"
;
}
}
return
$text
;
...
...
@@ -176,7 +132,7 @@ function remove_news($remove_array)
if
(
$text
)
{
$question_text
[]
=
$text
;
}
// or just remove range_id(s)?
// or just remove range_id(s)?
}
else
{
$text
=
''
;
if
(
$confirmed
&&
!
$remove_news
->
isNew
()
&&
count
(
$ranges
))
{
...
...
@@ -209,10 +165,10 @@ function remove_news($remove_array)
}
elseif
(
!
$confirmed
)
{
if
(
count
(
$ranges
)
===
1
)
{
$text
=
sprintf
(
_
(
'- Die Ankündigung "%s" wird aus dem aktiven Bereich entfernt. '
.
'Sie wird dadurch nicht endgültig gelöscht. Es wird nur die Zuordnung entfernt.'
),
$remove_news_title
)
.
"
\n
"
;
.
'Sie wird dadurch nicht endgültig gelöscht. Es wird nur die Zuordnung entfernt.'
),
$remove_news_title
)
.
"
\n
"
;
}
elseif
(
count
(
$ranges
)
>
1
)
{
$text
=
sprintf
(
_
(
'- Die Ankündigung "%s" wird aus den %s gewählten Bereichen entfernt. '
.
'Sie wird dadurch nicht endgültig gelöscht. Es werden nur die Zuordnungen entfernt.'
),
$remove_news_title
,
count
(
$ranges
))
.
"
\n
"
;
.
'Sie wird dadurch nicht endgültig gelöscht. Es werden nur die Zuordnungen entfernt.'
),
$remove_news_title
,
count
(
$ranges
))
.
"
\n
"
;
}
}
if
(
$text
)
{
...
...
@@ -232,19 +188,21 @@ function remove_news($remove_array)
/**
*
* @param
unknown_type
$range_id
* @param
unknown_type
$type
* @param
string
$range_id
* @param
string
$type
*/
function
show_rss_news
(
$range_id
,
$type
)
{
$item_url_fmt
=
'%1$s&contentbox_open=%2$s#%2$s'
;
$title
=
''
;
$studip_url
=
''
;
$description
=
''
;
switch
(
$type
){
case
'user'
:
$studip_url
=
$GLOBALS
[
'ABSOLUTE_URI_STUDIP'
]
.
'dispatch.php/profile?again=yes&username='
.
get_username
(
$range_id
);
$title
=
get_fullname
(
$range_id
)
.
' (Stud.IP - '
.
Config
::
get
()
->
UNI_NAME_CLEAN
.
')'
;
$description
=
_
(
'Persönliche Neuigkeiten'
)
.
' '
.
$title
;
break
;
break
;
case
'sem'
:
$studip_url
=
$GLOBALS
[
'ABSOLUTE_URI_STUDIP'
]
.
'dispatch.php/course/overview?cid='
.
$range_id
;
$sem_obj
=
Seminar
::
GetInstance
(
$range_id
);
...
...
@@ -254,7 +212,7 @@ function show_rss_news($range_id, $type)
$title
=
$sem_obj
->
getName
()
.
' (Stud.IP - '
.
Config
::
get
()
->
UNI_NAME_CLEAN
.
')'
;
$description
=
_
(
'Neuigkeiten der Veranstaltung'
)
.
' '
.
$title
;
break
;
break
;
case
'inst'
:
$studip_url
=
$GLOBALS
[
'ABSOLUTE_URI_STUDIP'
]
.
'dispatch.php/institute/overview?auswahl='
.
$range_id
;
$object_name
=
get_object_name
(
$range_id
,
$type
);
...
...
@@ -264,12 +222,12 @@ function show_rss_news($range_id, $type)
}
$title
=
$object_name
[
'name'
]
.
' (Stud.IP - '
.
Config
::
get
()
->
UNI_NAME_CLEAN
.
')'
;
$description
=
_
(
'Neuigkeiten der Einrichtung'
)
.
' '
.
$title
;
break
;
break
;
case
'global'
:
$studip_url
=
$GLOBALS
[
'ABSOLUTE_URI_STUDIP'
]
.
'dispatch.php/start?again=yes'
;
$title
=
'Stud.IP - '
.
Config
::
get
()
->
UNI_NAME_CLEAN
;
$description
=
_
(
'Allgemeine Neuigkeiten'
)
.
' '
.
$title
;
break
;
break
;
}
$items
=
StudipNews
::
GetNewsByRange
(
$range_id
,
true
,
true
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment