Commit d8261a067b77553fbe99aee6b55a3072b6cf7492

Authored by Jarrett Jordaan
1 parent 3272527d

PT-2631536 : Added delete triggers on document checkin for thumbnail, instaView …

…and pdfConverter plugins

Committed by: Jarrett Jordaan

Reviewed by: Megan Watson
plugins/pdfConverter/pdfConverterPlugin.php
... ... @@ -48,7 +48,7 @@ class DeletePDFTrigger {
48 48 }
49 49  
50 50 /**
51   - * On deleting a document, send the document owner and alert creator a notification email
  51 + * On deleting/checkin a document, send the document owner and alert creator a notification email
52 52 */
53 53 function postValidate() {
54 54 $oDoc = $this->aInfo['document'];
... ... @@ -85,6 +85,7 @@ class pdfConverterPlugin extends KTPlugin {
85 85 $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'pdfConverter.php';
86 86 $this->registerProcessor('PDFConverter', 'pdf.converter.processor', $dir);
87 87 $this->registerTrigger('delete', 'postValidate', 'DeletePDFTrigger','pdf.converter.triggers.delete', __FILE__);
  88 + $this->registerTrigger('checkin', 'postValidate', 'DeletePDFTrigger','pdf.triggers.delete.document.checkin', __FILE__);
88 89 }
89 90 }
90 91  
... ...
plugins/thumbnails/thumbnailsPlugin.php
... ... @@ -39,6 +39,34 @@
39 39 require_once(KT_LIB_DIR . '/plugins/plugin.inc.php');
40 40 require_once(KT_LIB_DIR . '/plugins/pluginregistry.inc.php');
41 41  
  42 +class DeleteThumbnailTrigger {
  43 + var $namespace = 'thumbnail.triggers.delete.document.checkin';
  44 + var $aInfo = null;
  45 +
  46 + function setInfo($aInfo) {
  47 + $this->aInfo = $aInfo;
  48 + }
  49 +
  50 + /**
  51 + * On checkin of a document, delete the thumbnail so a new one can be generated
  52 + */
  53 + function postValidate() {
  54 + $oDoc = $this->aInfo['document'];
  55 + $docId = $oDoc->getId();
  56 + $docInfo = array('id' => $docId, 'name' => $oDoc->getName());
  57 +
  58 + // Delete the pdf document
  59 + global $default;
  60 + $varDirectory = $default->varDirectory;
  61 +
  62 + $file = $varDirectory . DIRECTORY_SEPARATOR . "thumbnails" . DIRECTORY_SEPARATOR .$docId.'.jpg';
  63 +
  64 + if(file_exists($file)){
  65 + @unlink($file);
  66 + }
  67 + }
  68 +}
  69 +
42 70 class thumbnailsPlugin extends KTPlugin {
43 71 var $sNamespace = 'thumbnails.generator.processor.plugin';
44 72 var $iVersion = 0;
... ... @@ -61,6 +89,7 @@ class thumbnailsPlugin extends KTPlugin {
61 89 $this->registerProcessor('thumbnailGenerator', 'thumbnails.generator.processor', $dir);
62 90 $this->registerAction('documentviewlet', 'ThumbnailViewlet', 'thumbnail.viewlets', $dir);
63 91 $this->registerColumn(_kt('Thumbnail'), 'thumbnails.generator.column', 'ThumbnailColumn', $dir);
  92 + $this->registerTrigger('checkin', 'postValidate', 'DeleteThumbnailTrigger','thumbnail.triggers.delete.document.checkin', __FILE__);
64 93  
65 94 require_once(KT_LIB_DIR . '/templating/templating.inc.php');
66 95 $oTemplating =& KTTemplating::getSingleton();
... ...