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
Terraform modules
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
Jakob Diel
Stud.IP
Commits
7f1bdc86
Commit
7f1bdc86
authored
3 years ago
by
David Siegfried
Browse files
Options
Downloads
Patches
Plain Diff
Delete clipboard items when room is deleted, closes #361
parent
87ef660b
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/routes/Clipboard.php
+6
-8
6 additions, 8 deletions
app/routes/Clipboard.php
lib/models/resources/Room.class.php
+9
-3
9 additions, 3 deletions
lib/models/resources/Room.class.php
resources/assets/javascripts/lib/clipboard.js
+6
-4
6 additions, 4 deletions
resources/assets/javascripts/lib/clipboard.js
with
21 additions
and
15 deletions
app/routes/Clipboard.php
+
6
−
8
View file @
7f1bdc86
...
...
@@ -60,7 +60,7 @@ class Clipboard extends \RESTAPI\RouteMap
if
(
$clipboard
->
user_id
!=
$GLOBALS
[
'user'
]
->
id
)
{
//Thou shalt not delete clipboards
//which don't belong to you!
throw
new
AccessDeniedException
();
throw
new
\
AccessDeniedException
();
}
$name
=
$this
->
data
[
'name'
];
...
...
@@ -70,8 +70,6 @@ class Clipboard extends \RESTAPI\RouteMap
$clipboard
->
name
=
$name
;
$success
=
false
;
if
(
$clipboard
->
isDirty
())
{
$success
=
$clipboard
->
store
();
}
else
{
...
...
@@ -107,10 +105,10 @@ class Clipboard extends \RESTAPI\RouteMap
$this
->
notFound
(
_
(
'Ungültige Merkzettel-ID!'
));
}
if
(
$clipboard
->
user_id
!=
$GLOBALS
[
'user'
]
->
id
)
{
if
(
$clipboard
->
user_id
!=
=
$GLOBALS
[
'user'
]
->
id
)
{
//Thou shalt not delete items of clipboards
//which don't belong to you!
throw
new
AccessDeniedException
();
throw
new
\
AccessDeniedException
();
}
if
(
!
$clipboard
->
delete
())
{
...
...
@@ -136,7 +134,7 @@ class Clipboard extends \RESTAPI\RouteMap
if
(
$clipboard
->
user_id
!=
$GLOBALS
[
'user'
]
->
id
)
{
//Thou shalt not add items to clipboards
//which don't belong to you!
throw
new
AccessDeniedException
();
throw
new
\
AccessDeniedException
();
}
$range_id
=
\Request
::
get
(
'range_id'
);
...
...
@@ -162,7 +160,7 @@ class Clipboard extends \RESTAPI\RouteMap
$result
[
'widget_id'
]
=
$widget_id
;
}
return
$result
;
}
catch
(
Exception
$e
)
{
}
catch
(
\
Exception
$e
)
{
$this
->
halt
(
500
,
$e
->
getMessage
());
}
}
...
...
@@ -183,7 +181,7 @@ class Clipboard extends \RESTAPI\RouteMap
if
(
$clipboard
->
user_id
!=
$GLOBALS
[
'user'
]
->
id
)
{
//Thou shalt not delete items of clipboards
//which don't belong to you!
throw
new
AccessDeniedException
();
throw
new
\
AccessDeniedException
();
}
if
(
$clipboard
->
removeItem
(
$range_id
))
{
...
...
This diff is collapsed.
Click to expand it.
lib/models/resources/Room.class.php
+
9
−
3
View file @
7f1bdc86
...
...
@@ -52,6 +52,7 @@ class Room extends Resource
$config
[
'additional_fields'
][
'building'
][
'get'
]
=
'findBuilding'
;
$config
[
'registered_callbacks'
][
'before_store'
][]
=
'cbValidate'
;
$config
[
'registered_callbacks'
][
'after_delete'
][]
=
'cbDeleteClipboardItems'
;
parent
::
configure
(
$config
);
}
...
...
@@ -155,7 +156,7 @@ class Room extends Resource
* @param int $limit A limit for the result set.
* @param Room[] $searchable_rooms An (optional) array of rooms
* which will limit the search to the rooms in the array.
* @param
A
rray $properties An array providing request properties
* @param
a
rray $properties An array providing request properties
* and their values in case the request doesn't have (the desired)
* properties set.
*
...
...
@@ -324,7 +325,7 @@ class Room extends Resource
/**
* Checks wheter rooms with public booking plans exist.
* Checks whet
h
er rooms with public booking plans exist.
*
* @return bool True, if at least one room has a public booking plan,
* false otherwise.
...
...
@@ -506,6 +507,11 @@ class Room extends Resource
return
true
;
}
public
function
cbDeleteClipboardItems
()
{
ClipboardItem
::
deleteBySQL
(
'range_id = ?'
,
[
$this
->
id
]);
}
public
function
getRequiredPropertyNames
()
{
...
...
@@ -554,7 +560,7 @@ class Room extends Resource
*
* @param Resource $resource The resource which shall be added as child.
*
* @return True, if the resource could be added as child, false otherwise.
* @return
bool
True, if the resource could be added as child, false otherwise.
* @throws InvalidResourceException If the specified resource belongs to
* the resource classes Room, Building or Location.
*
...
...
This diff is collapsed.
Click to expand it.
resources/assets/javascripts/lib/clipboard.js
+
6
−
4
View file @
7f1bdc86
import
{
$gettext
}
from
'
./gettext
'
;
const
Clipboard
=
{
current_delete_icon
:
null
,
...
...
@@ -19,7 +21,7 @@ const Clipboard = {
var
current_clipboard_id
=
jQuery
(
clipboard
).
attr
(
'
data-id
'
);
if
(
current_clipboard_id
)
{
if
(
current_clipboard_id
==
selected_clipboard_id
)
{
if
(
current_clipboard_id
==
=
selected_clipboard_id
)
{
jQuery
(
clipboard
).
removeClass
(
'
invisible
'
);
if
(
jQuery
(
clipboard
).
find
(
"
.empty-clipboard-message
"
).
hasClass
(
"
invisible
"
))
{
jQuery
(
"
#clipboard-group-container
"
).
find
(
'
.widget-links
'
).
removeClass
(
'
invisible
'
);
...
...
@@ -213,7 +215,7 @@ const Clipboard = {
//don't belong on the displayed page. That's all.
allowed_classes
=
allowed_classes
.
replace
(
'
'
,
''
).
split
(
'
,
'
);
if
(
allowed_classes
.
indexOf
(
range_type
)
==
-
1
)
{
if
(
allowed_classes
.
indexOf
(
range_type
)
==
=
-
1
)
{
//The dropped item does not belong to the right class.
//Set the "not allowed" CSS class
//for the "not allowed" animation.
...
...
@@ -432,7 +434,7 @@ const Clipboard = {
confirmRemoveClick
:
function
(
event
)
{
STUDIP
.
Clipboard
.
current_delete_icon
=
event
.
target
;
STUDIP
.
Dialog
.
confirm
(
'
Sind Sie sicher?
'
,
$gettext
(
'
Sind Sie sicher?
'
)
,
STUDIP
.
Clipboard
.
handleRemoveClick
);
},
...
...
@@ -475,7 +477,7 @@ const Clipboard = {
confirmRemoveItemClick
:
function
(
event
)
{
STUDIP
.
Clipboard
.
current_delete_icon
=
event
.
target
;
STUDIP
.
Dialog
.
confirm
(
'
Sind Sie sicher?
'
,
$gettext
(
'
Sind Sie sicher?
'
)
,
STUDIP
.
Clipboard
.
removeItem
);
},
...
...
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