Commit 36ee490e authored by Son Nguyen's avatar Son Nguyen
Browse files

Fix the issue when deleting a skin (Bug 1264105)



also display number of views using the skin to delete

Change-Id: I64faac110c8caa84ef28195368afdfbec8b0bc76
Signed-off-by: default avatarSon Nguyen <son.nguyen@catalyst.net.nz>
parent ed81b8ac
......@@ -21,6 +21,7 @@ $string['skindeleted'] = 'Skin deleted';
$string['cantdeleteskin'] = 'You cannot delete this skin.';
$string['deletespecifiedskin'] = 'Delete skin \'%s\'';
$string['deleteskinconfirm'] = 'Do you really want to delete this skin? It cannot be undone.';
$string['deleteskinusedinpages'] = 'The skin you are about to delete is used in %d page(s).';
$string['importskins'] = 'Import skin(s)';
$string['importskinsnotice'] = 'Please select a valid XML file to import, which contains the definition(s) of the skin(s).';
$string['validxmlfile'] = 'Valid XML file';
......
......@@ -196,7 +196,9 @@ class Skin {
*/
public function delete() {
db_begin();
delete_records('skin','id',$this->id);
delete_records('skin', 'id', $this->id);
// Reset the view's skin
set_field('view', 'skin', null, 'skin', $this->id);
$this->deleted = true;
db_commit();
}
......
......@@ -38,14 +38,16 @@ if (!$skin->can_edit()) {
define('TITLE', get_string('deletespecifiedskin', 'skin', $skin->get('title')));
$numberofpagesuseskin = count_records('view', 'skin', $skin->get('id'));
$form = pieform(array(
'name' => 'deleteskin',
'autofocus' => false,
'renderer' => 'div',
'method' => 'post',
'elements' => array(
'submit' => array(
'type' => 'submitcancel',
'title' => get_string('deleteskinconfirm', 'skin'),
'value' => array(get_string('yes'), get_string('no')),
'goto' => get_config('wwwroot') . $goto,
)
......@@ -53,9 +55,10 @@ $form = pieform(array(
));
$smarty = smarty();
$smarty->assign('PAGEHEADING', hsc(TITLE));
$smarty->assign('PAGEHEADING', get_string('deletespecifiedskin', 'skin', $skin->get('title')));
$smarty->assign('safemessage', (($numberofpagesuseskin > 0) ? get_string('deleteskinusedinpages', 'skin', $numberofpagesuseskin) . '<br/>' : '') . get_string('deleteskinconfirm', 'skin'));
$smarty->assign('form', $form);
$smarty->display('form.tpl');
$smarty->display('skin/delete.tpl');
function deleteskin_submit(Pieform $form, $values) {
global $SESSION, $USER, $skinid, $redirect;
......
{include file="header.tpl"}
<div class="message delete">
<h3>{$subheading}</h3>
<p>{$safemessage|clean_html|safe}</p>
{$form|safe}
</div>
{include file="footer.tpl"}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment