Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
f8ba3cb6
Commit
f8ba3cb6
authored
Feb 13, 2017
by
Robert Lyon
Committed by
Gerrit Code Review
Feb 13, 2017
Browse files
Merge "Bug 1661139: add delete option in view screen"
parents
bc353c69
d2987e63
Changes
4
Hide whitespace changes
Inline
Side-by-side
htdocs/lib/view.php
View file @
f8ba3cb6
...
...
@@ -872,7 +872,9 @@ class View {
delete_records
(
'view_autocreate_grouptype'
,
'view'
,
$this
->
id
);
delete_records
(
'view_tag'
,
'view'
,
$this
->
id
);
delete_records
(
'view_visit'
,
'view'
,
$this
->
id
);
delete_records
(
'collection_view'
,
'view'
,
$this
->
id
);
if
(
$collection
=
$this
->
get_collection
())
{
$collection
->
remove_view
(
$this
->
id
);
}
delete_records
(
'usr_watchlist_view'
,
'view'
,
$this
->
id
);
if
(
$blockinstanceids
=
get_column
(
'block_instance'
,
'id'
,
'view'
,
$this
->
id
))
{
require_once
(
get_config
(
'docroot'
)
.
'blocktype/lib.php'
);
...
...
htdocs/theme/raw/templates/view/view.tpl
View file @
f8ba3cb6
...
...
@@ -59,24 +59,35 @@
{
str
tag
=
print
section
=
view
}
</a>
</li>
{
if
$LOGGEDIN
&&
!
$userisowner
}
<li>
<a
id=
"toggle_watchlist_link"
class=
"watchlist"
href=
""
>
{
if
$viewbeingwatched
}
<span
class=
"icon icon-eye-slash left"
role=
"presentation"
aria-hidden=
"true"
></span>
{
str
tag
=
removefromwatchlist
section
=
view
}
{
else
}
<span
class=
"icon icon-eye left"
role=
"presentation"
aria-hidden=
"true"
></span>
{
str
tag
=
addtowatchlist
section
=
view
}
{/
if
}
</a>
</li>
<li>
<a
id=
"objection_link"
href=
"#"
data-toggle=
"modal"
data-target=
"#report-form"
>
<span
class=
"icon icon-lg icon-flag text-danger left"
role=
"presentation"
aria-hidden=
"true"
></span>
{
str
tag
=
reportobjectionablematerial
}
</a>
</li>
{
if
$LOGGEDIN
}
{
if
!
$userisowner
}
<li>
<a
id=
"toggle_watchlist_link"
class=
"watchlist"
href=
""
>
{
if
$viewbeingwatched
}
<span
class=
"icon icon-eye-slash left"
role=
"presentation"
aria-hidden=
"true"
></span>
{
str
tag
=
removefromwatchlist
section
=
view
}
{
else
}
<span
class=
"icon icon-eye left"
role=
"presentation"
aria-hidden=
"true"
></span>
{
str
tag
=
addtowatchlist
section
=
view
}
{/
if
}
</a>
</li>
<li>
<a
id=
"objection_link"
href=
"#"
data-toggle=
"modal"
data-target=
"#report-form"
>
<span
class=
"icon icon-lg icon-flag text-danger left"
role=
"presentation"
aria-hidden=
"true"
></span>
{
str
tag
=
reportobjectionablematerial
}
</a>
</li>
{/
if
}
{
if
$userisowner
||
$canremove
}
<li>
<a
href=
"
{
$WWWROOT
}
view/delete.php?id=
{
$viewid
}
"
title=
"
{
str
tag
=
deletethisview
section
=
view
}
"
>
<span
class=
"icon icon-lg icon-trash text-danger"
role=
"presentation"
aria-hidden=
"true"
></span>
<span
class=
"sr-only"
>
{
str
(
tag
=
deletespecific
arg1
=
$maintitle
)|
escape
:
html
|
safe
}
</span>
{
str
tag
=
deletethisview
section
=
view
}
</a>
</li>
{/
if
}
{/
if
}
</ul>
</div>
...
...
htdocs/view/delete.php
View file @
f8ba3cb6
...
...
@@ -33,17 +33,41 @@ if ($collection) {
$institution
=
$view
->
get
(
'institution'
);
View
::
set_nav
(
$groupid
,
$institution
);
if
(
$groupid
)
{
$goto
=
'groupviews.php?group='
.
$groupid
;
//pressing the delete button from inside page view that belongs to a collection
if
(
$collection
)
{
$views
=
$collection
->
get_viewids
();
if
((
$key
=
array_search
(
$viewid
,
$views
))
!==
false
)
{
unset
(
$views
[
$key
]);
}
if
(
$id
=
reset
(
$views
))
{
if
(
$collection
->
has_framework
())
{
$goto
=
'module/framework/matrix.php?id='
.
$collection
->
get
(
'id'
);
}
else
{
$goto
=
'view/view.php?id='
.
$id
;
}
}
else
{
$goto
=
'collection/index.php'
;
if
(
$groupid
)
{
$goto
.
=
'?group='
.
$groupid
;
}
else
if
(
$institution
)
{
$goto
.
=
'?institution='
.
$institution
;
}
}
}
else
if
(
$groupid
)
{
$goto
=
'view/groupviews.php?group='
.
$groupid
;
}
else
if
(
$institution
)
{
$goto
=
'institutionviews.php?institution='
.
$institution
;
$goto
=
'
view/
institutionviews.php?institution='
.
$institution
;
}
else
{
$query
=
get_querystring
();
// remove the id
$query
=
preg_replace
(
'/id=([0-9]+)\&/'
,
''
,
$query
);
$goto
=
'index.php?'
.
$query
;
$goto
=
'
view/
index.php?'
.
$query
;
}
define
(
'TITLE'
,
get_string
(
'deletespecifiedview'
,
'view'
,
$view
->
get
(
'title'
)));
...
...
@@ -58,7 +82,7 @@ $form = pieform(array(
'type'
=>
'submitcancel'
,
'class'
=>
'btn-default'
,
'value'
=>
array
(
get_string
(
'yes'
),
get_string
(
'no'
)),
'goto'
=>
get_config
(
'wwwroot'
)
.
'view/'
.
$goto
,
'goto'
=>
get_config
(
'wwwroot'
)
.
$goto
,
)
),
));
...
...
@@ -70,20 +94,19 @@ $smarty->assign('collectionnote', $collectionnote);
$smarty
->
display
(
'view/delete.tpl'
);
function
deleteview_submit
(
Pieform
$form
,
$values
)
{
global
$SESSION
,
$USER
,
$viewid
,
$groupid
,
$institution
,
$goto
;
global
$SESSION
,
$USER
,
$viewid
,
$groupid
,
$institution
;
$submitelement
=
$form
->
get_element
(
'submit'
);
$view
=
new
View
(
$viewid
,
null
);
if
(
View
::
can_remove_viewtype
(
$view
->
get
(
'type'
))
||
$USER
->
get
(
'admin'
))
{
$collectionid
=
$view
->
collection_id
();
$view
->
delete
();
if
(
$collection
=
new
Collection
(
$collectionid
))
{
$collection
->
update_display_order
();
}
$SESSION
->
add_ok_msg
(
get_string
(
'viewdeleted'
,
'view'
));
}
else
{
$SESSION
->
add_error_msg
(
get_string
(
'cantdeleteview'
,
'view'
));
}
if
(
$groupid
)
{
redirect
(
'/view/groupviews.php?group='
.
$groupid
);
}
if
(
$institution
)
{
redirect
(
'/view/institutionviews.php?institution='
.
$institution
);
}
redirect
(
'/view/'
.
$goto
);
redirect
(
$submitelement
[
'goto'
]);
}
htdocs/view/view.php
View file @
f8ba3cb6
...
...
@@ -346,6 +346,7 @@ if ($collection) {
}
}
$smarty
->
assign
(
'canremove'
,
$can_edit
);
$smarty
->
assign
(
'INLINEJAVASCRIPT'
,
$javascript
.
$inlinejs
);
$smarty
->
assign
(
'new'
,
$new
);
$smarty
->
assign
(
'viewid'
,
$viewid
);
...
...
Write
Preview
Supports
Markdown
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