Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gredu_labs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Σταύρος Παπαδάκης
gredu_labs
Commits
857e0323
Commit
857e0323
authored
Mar 01, 2016
by
Vassilis Kanellopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove lab action
parent
c633655a
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
82 additions
and
2 deletions
+82
-2
config/settings/acl.global.php
config/settings/acl.global.php
+1
-1
module/schools/bootstrap.php
module/schools/bootstrap.php
+7
-0
module/schools/public/js/schools/labs.js
module/schools/public/js/schools/labs.js
+1
-1
module/schools/src/Action/Lab/DeleteLab.php
module/schools/src/Action/Lab/DeleteLab.php
+54
-0
module/schools/src/Service/LabService.php
module/schools/src/Service/LabService.php
+17
-0
module/schools/src/Service/LabServiceInterface.php
module/schools/src/Service/LabServiceInterface.php
+1
-0
module/schools/templates/schools/labs.twig
module/schools/templates/schools/labs.twig
+1
-0
No files found.
config/settings/acl.global.php
View file @
857e0323
...
@@ -24,7 +24,7 @@ return [
...
@@ -24,7 +24,7 @@ return [
[
'/'
,
[
'guest'
,
'user'
],
[
'get'
]],
[
'/'
,
[
'guest'
,
'user'
],
[
'get'
]],
[
'/about'
,
[
'guest'
,
'user'
],
[
'get'
]],
[
'/about'
,
[
'guest'
,
'user'
],
[
'get'
]],
[
'/school'
,
[
'school'
],
[
'get'
]],
[
'/school'
,
[
'school'
],
[
'get'
]],
[
'/school/labs'
,
[
'school'
],
[
'get'
,
'post'
]],
[
'/school/labs'
,
[
'school'
],
[
'get'
,
'post'
,
'delete'
]],
[
'/school/staff'
,
[
'school'
],
[
'get'
,
'post'
,
'delete'
]],
[
'/school/staff'
,
[
'school'
],
[
'get'
,
'post'
,
'delete'
]],
[
'/school/assets'
,
[
'school'
],
[
'get'
,
'post'
,
'delete'
]],
[
'/school/assets'
,
[
'school'
],
[
'get'
,
'post'
,
'delete'
]],
[
'/school/labs/attachment'
,
[
'school'
],
[
'get'
,
'delete'
]],
[
'/school/labs/attachment'
,
[
'school'
],
[
'get'
,
'delete'
]],
...
...
module/schools/bootstrap.php
View file @
857e0323
...
@@ -66,6 +66,12 @@ return function (Slim\App $app) {
...
@@ -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
)
{
$container
[
Action\Lab\DownloadAttachment
::
class
]
=
function
(
$c
)
{
$settings
=
$c
->
get
(
'settings'
);
$settings
=
$c
->
get
(
'settings'
);
$uploadTargetPath
=
$settings
[
'schools'
][
'file_upload'
][
'target_path'
];
$uploadTargetPath
=
$settings
[
'schools'
][
'file_upload'
][
'target_path'
];
...
@@ -210,6 +216,7 @@ return function (Slim\App $app) {
...
@@ -210,6 +216,7 @@ return function (Slim\App $app) {
$this
->
get
(
'/labs'
,
Action\Lab\ListAll
::
class
)
->
setName
(
'school.labs'
);
$this
->
get
(
'/labs'
,
Action\Lab\ListAll
::
class
)
->
setName
(
'school.labs'
);
$this
->
post
(
'/labs'
,
Action\Lab\PersistLab
::
class
)
$this
->
post
(
'/labs'
,
Action\Lab\PersistLab
::
class
)
->
add
(
Middleware\InputFilterLab
::
class
);
->
add
(
Middleware\InputFilterLab
::
class
);
$this
->
delete
(
'/labs'
,
Action\Lab\DeleteLab
::
class
);
$this
->
get
(
'/labs/attachment'
,
Action\Lab\DownloadAttachment
::
class
)
$this
->
get
(
'/labs/attachment'
,
Action\Lab\DownloadAttachment
::
class
)
->
setName
(
'school.labs.attachment'
);
->
setName
(
'school.labs.attachment'
);
$this
->
delete
(
'/labs/attachment'
,
Action\Lab\RemoveAttachment
::
class
);
$this
->
delete
(
'/labs/attachment'
,
Action\Lab\RemoveAttachment
::
class
);
...
...
module/schools/public/js/schools/labs.js
View file @
857e0323
...
@@ -202,7 +202,7 @@
...
@@ -202,7 +202,7 @@
id
:
that
.
lab
.
get
(
'
id
'
)
id
:
that
.
lab
.
get
(
'
id
'
)
}
}
}).
done
(
function
()
{
}).
done
(
function
()
{
that
.
model
.
remove
(
that
.
asset
.
get
(
'
id
'
));
that
.
model
.
remove
(
that
.
lab
.
get
(
'
id
'
));
that
.
hide
();
that
.
hide
();
}).
fail
(
function
(
xhr
,
err
){
}).
fail
(
function
(
xhr
,
err
){
alert
(
'
Δεν ήταν δυνατή η διαγραφή του χώρου
'
);
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
...
@@ -197,4 +197,21 @@ class LabService implements LabServiceInterface
$lab
->
attachment_mime
=
null
;
$lab
->
attachment_mime
=
null
;
R
::
store
(
$lab
);
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
...
@@ -16,6 +16,7 @@ interface LabServiceInterface
public
function
getLabById
(
$id
);
public
function
getLabById
(
$id
);
public
function
getLabsBySchoolId
(
$id
);
public
function
getLabsBySchoolId
(
$id
);
public
function
getLabForSchool
(
$school_id
,
$id
);
public
function
getLabForSchool
(
$school_id
,
$id
);
public
function
removeLab
(
$id
,
$school_id
=
null
);
public
function
removeLabAttachment
(
$lab_id
);
public
function
removeLabAttachment
(
$lab_id
);
...
...
module/schools/templates/schools/labs.twig
View file @
857e0323
...
@@ -90,6 +90,7 @@
...
@@ -90,6 +90,7 @@
<input
type=
"hidden"
name=
"id"
value=
""
>
<input
type=
"hidden"
name=
"id"
value=
""
>
</div>
</div>
<div
class=
"modal-footer"
>
<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
type=
"button"
class=
"btn btn-default"
data-dismiss=
"modal"
>
Κλείσιμο
</button>
<button
name=
"submit"
value=
"submit"
type=
"submit"
class=
"btn btn-primary"
>
Αποθήκευση
</button>
<button
name=
"submit"
value=
"submit"
type=
"submit"
class=
"btn btn-primary"
>
Αποθήκευση
</button>
</div>
</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