Permalink
Browse files

Add category photo delete button

Conflicts:
	applications/vanilla/views/settings/editcategory.php
  • Loading branch information...
linc committed Apr 10, 2013
1 parent eb3aaf9 commit 5d357c129ebb3e0e6c6f7f5ef6aa8e2161cc745a
@@ -356,6 +356,36 @@ public function DeleteCategory($CategoryID = FALSE) {
// Render default view
$this->Render();
}
/**
* Deleting a category photo.
*
* @since 2.1
* @access public
*
* @param int $CategoryID Unique ID of the category to have its photo deleted.
*/
public function DeleteCategoryPhoto($CategoryID = FALSE, $TransientKey = '') {
// Check permission
$this->Permission('Garden.Settings.Manage');
$RedirectUrl = 'vanilla/settings/editcategory/'.$CategoryID;
if (Gdn::Session()->ValidateTransientKey($TransientKey)) {
// Do removal, set message, redirect
$CategoryModel = new CategoryModel();
$CategoryModel->SetField($CategoryID, 'Photo', NULL);
$this->InformMessage(T('Category photo has been deleted.'));
}
if ($this->_DeliveryType == DELIVERY_TYPE_ALL) {
Redirect($RedirectUrl);
} else {
$this->ControllerName = 'Home';
$this->View = 'FileNotFound';
$this->RedirectUrl = Url($RedirectUrl);
$this->Render();
}
}
/**
* Editing a category.
@@ -43,6 +43,9 @@
echo $this->Form->Label('Photo', 'PhotoUpload');
if ($Photo = $this->Form->GetValue('Photo')) {
echo Img(Gdn_Upload::Url($Photo));
echo '<br />'.Anchor(T('Delete Photo'),
CombinePaths(array('vanilla/settings/deletecategoryphoto', $this->Category->CategoryID, Gdn::Session()->TransientKey())),
'SmallButton Danger PopConfirm');
}
echo $this->Form->Input('PhotoUpload', 'file');
?>

0 comments on commit 5d357c1

Please sign in to comment.