From d8261a067b77553fbe99aee6b55a3072b6cf7492 Mon Sep 17 00:00:00 2001 From: Jarrett Jordaan Date: Fri, 12 Mar 2010 15:29:43 +0200 Subject: [PATCH] PT-2631536 : Added delete triggers on document checkin for thumbnail, instaView and pdfConverter plugins --- plugins/pdfConverter/pdfConverterPlugin.php | 3 ++- plugins/thumbnails/thumbnailsPlugin.php | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/plugins/pdfConverter/pdfConverterPlugin.php b/plugins/pdfConverter/pdfConverterPlugin.php index 50a04db..565621c 100644 --- a/plugins/pdfConverter/pdfConverterPlugin.php +++ b/plugins/pdfConverter/pdfConverterPlugin.php @@ -48,7 +48,7 @@ class DeletePDFTrigger { } /** - * On deleting a document, send the document owner and alert creator a notification email + * On deleting/checkin a document, send the document owner and alert creator a notification email */ function postValidate() { $oDoc = $this->aInfo['document']; @@ -85,6 +85,7 @@ class pdfConverterPlugin extends KTPlugin { $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'pdfConverter.php'; $this->registerProcessor('PDFConverter', 'pdf.converter.processor', $dir); $this->registerTrigger('delete', 'postValidate', 'DeletePDFTrigger','pdf.converter.triggers.delete', __FILE__); + $this->registerTrigger('checkin', 'postValidate', 'DeletePDFTrigger','pdf.triggers.delete.document.checkin', __FILE__); } } diff --git a/plugins/thumbnails/thumbnailsPlugin.php b/plugins/thumbnails/thumbnailsPlugin.php index ace843c..0aa894d 100644 --- a/plugins/thumbnails/thumbnailsPlugin.php +++ b/plugins/thumbnails/thumbnailsPlugin.php @@ -39,6 +39,34 @@ require_once(KT_LIB_DIR . '/plugins/plugin.inc.php'); require_once(KT_LIB_DIR . '/plugins/pluginregistry.inc.php'); +class DeleteThumbnailTrigger { + var $namespace = 'thumbnail.triggers.delete.document.checkin'; + var $aInfo = null; + + function setInfo($aInfo) { + $this->aInfo = $aInfo; + } + + /** + * On checkin of a document, delete the thumbnail so a new one can be generated + */ + function postValidate() { + $oDoc = $this->aInfo['document']; + $docId = $oDoc->getId(); + $docInfo = array('id' => $docId, 'name' => $oDoc->getName()); + + // Delete the pdf document + global $default; + $varDirectory = $default->varDirectory; + + $file = $varDirectory . DIRECTORY_SEPARATOR . "thumbnails" . DIRECTORY_SEPARATOR .$docId.'.jpg'; + + if(file_exists($file)){ + @unlink($file); + } + } +} + class thumbnailsPlugin extends KTPlugin { var $sNamespace = 'thumbnails.generator.processor.plugin'; var $iVersion = 0; @@ -61,6 +89,7 @@ class thumbnailsPlugin extends KTPlugin { $this->registerProcessor('thumbnailGenerator', 'thumbnails.generator.processor', $dir); $this->registerAction('documentviewlet', 'ThumbnailViewlet', 'thumbnail.viewlets', $dir); $this->registerColumn(_kt('Thumbnail'), 'thumbnails.generator.column', 'ThumbnailColumn', $dir); + $this->registerTrigger('checkin', 'postValidate', 'DeleteThumbnailTrigger','thumbnail.triggers.delete.document.checkin', __FILE__); require_once(KT_LIB_DIR . '/templating/templating.inc.php'); $oTemplating =& KTTemplating::getSingleton(); -- libgit2 0.21.4