Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
gredu_labs
Commits
857e0323
Commit
857e0323
authored
Mar 01, 2016
by
Vassilis Kanellopoulos
Browse files
remove lab action
parent
c633655a
Changes
7
Hide whitespace changes
Inline
Side-by-side
config/settings/acl.global.php
View file @
857e0323
...
...
@@ -24,7 +24,7 @@ return [
[
'/'
,
[
'guest'
,
'user'
],
[
'get'
]],
[
'/about'
,
[
'guest'
,
'user'
],
[
'get'
]],
[
'/school'
,
[
'school'
],
[
'get'
]],
[
'/school/labs'
,
[
'school'
],
[
'get'
,
'post'
]],
[
'/school/labs'
,
[
'school'
],
[
'get'
,
'post'
,
'delete'
]],
[
'/school/staff'
,
[
'school'
],
[
'get'
,
'post'
,
'delete'
]],
[
'/school/assets'
,
[
'school'
],
[
'get'
,
'post'
,
'delete'
]],
[
'/school/labs/attachment'
,
[
'school'
],
[
'get'
,
'delete'
]],
...
...
module/schools/bootstrap.php
View file @
857e0323
...
...
@@ -66,6 +66,12 @@ return function (Slim\App $app) {
);
};
$container
[
Action\Lab\DeleteLab
::
class
]
=
function
(
$c
)
{
return
new
Action\Lab\DeleteLab
(
$c
->
get
(
Service\LabServiceInterface
::
class
)
);
};
$container
[
Action\Lab\DownloadAttachment
::
class
]
=
function
(
$c
)
{
$settings
=
$c
->
get
(
'settings'
);
$uploadTargetPath
=
$settings
[
'schools'
][
'file_upload'
][
'target_path'
];
...
...
@@ -210,6 +216,7 @@ return function (Slim\App $app) {
$this
->
get
(
'/labs'
,
Action\Lab\ListAll
::
class
)
->
setName
(
'school.labs'
);
$this
->
post
(
'/labs'
,
Action\Lab\PersistLab
::
class
)
->
add
(
Middleware\InputFilterLab
::
class
);
$this
->
delete
(
'/labs'
,
Action\Lab\DeleteLab
::
class
);
$this
->
get
(
'/labs/attachment'
,
Action\Lab\DownloadAttachment
::
class
)
->
setName
(
'school.labs.attachment'
);
$this
->
delete
(
'/labs/attachment'
,
Action\Lab\RemoveAttachment
::
class
);
...
...
module/schools/public/js/schools/labs.js
View file @
857e0323
...
...
@@ -202,7 +202,7 @@
id
:
that
.
lab
.
get
(
'
id
'
)
}
}).
done
(
function
()
{
that
.
model
.
remove
(
that
.
asset
.
get
(
'
id
'
));
that
.
model
.
remove
(
that
.
lab
.
get
(
'
id
'
));
that
.
hide
();
}).
fail
(
function
(
xhr
,
err
){
alert
(
'
Δεν ήταν δυνατή η διαγραφή του χώρου
'
);
...
...
module/schools/src/Action/Lab/DeleteLab.php
0 → 100644
View file @
857e0323
<?php
/**
* gredu_labs.
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
*
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
namespace
GrEduLabs\Schools\Action\Lab
;
use
Exception
;
use
GrEduLabs\Schools\Service\LabServiceInterface
;
use
Slim\Http\Request
;
use
Slim\Http\Response
;
class
DeleteLab
{
/**
*
* @var LabServiceInterface
*/
protected
$labService
;
public
function
__construct
(
LabServiceInterface
$labService
)
{
$this
->
labService
=
$labService
;
}
public
function
__invoke
(
Request
$req
,
Response
$res
)
{
$school
=
$req
->
getAttribute
(
'school'
,
false
);
if
(
!
$school
&&
!
$school
->
id
)
{
return
$res
->
withStatus
(
403
,
'No school'
);
}
$id
=
$req
->
getParam
(
'id'
,
false
);
if
(
!
$id
)
{
return
$res
->
withStatus
(
404
);
}
try
{
$this
->
labService
->
removeLab
(
$id
,
$school
->
id
);
$res
=
$res
->
withStatus
(
204
);
}
catch
(
Exception
$ex
)
{
$res
=
$res
->
withStatus
(
500
,
$ex
->
getMessage
());
}
return
$res
;
}
}
module/schools/src/Service/LabService.php
View file @
857e0323
...
...
@@ -197,4 +197,21 @@ class LabService implements LabServiceInterface
$lab
->
attachment_mime
=
null
;
R
::
store
(
$lab
);
}
public
function
removeLab
(
$id
,
$school_id
=
null
)
{
$sql
=
' id = ? '
;
$bindings
=
[(
int
)
$id
];
if
(
null
!==
$school_id
)
{
$sql
.
=
' AND school_id = ? '
;
$bindings
[]
=
(
int
)
$school_id
;
}
$lab
=
R
::
findOne
(
'lab'
,
$sql
,
$bindings
);
if
(
null
!==
$lab
)
{
if
(
$lab
->
attachment
&&
is_writable
(
$this
->
filesPath
.
'/'
.
$lab
->
attachment
))
{
unlink
(
$this
->
filesPath
.
'/'
.
$lab
->
attachment
);
}
R
::
trash
(
$lab
);
}
}
}
module/schools/src/Service/LabServiceInterface.php
View file @
857e0323
...
...
@@ -16,6 +16,7 @@ interface LabServiceInterface
public
function
getLabById
(
$id
);
public
function
getLabsBySchoolId
(
$id
);
public
function
getLabForSchool
(
$school_id
,
$id
);
public
function
removeLab
(
$id
,
$school_id
=
null
);
public
function
removeLabAttachment
(
$lab_id
);
...
...
module/schools/templates/schools/labs.twig
View file @
857e0323
...
...
@@ -90,6 +90,7 @@
<input
type=
"hidden"
name=
"id"
value=
""
>
</div>
<div
class=
"modal-footer"
>
<button
type=
"button"
class=
"btn btn-danger pull-left remove"
>
Διαγραφή
</button>
<button
type=
"button"
class=
"btn btn-default"
data-dismiss=
"modal"
>
Κλείσιμο
</button>
<button
name=
"submit"
value=
"submit"
type=
"submit"
class=
"btn btn-primary"
>
Αποθήκευση
</button>
</div>
...
...
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