Commit 25dbe6005076f9ba44db2d1e16c104cae2ccbc62

Authored by Megan Watson
1 parent 6f25184e

Added a button to re-process all documents for pdf generation. Added an sql upgrade to do the same.

PT: 1846155

Committed by: Megan Watson
plugins/search2/reporting/RescheduleDocuments.php
... ... @@ -5,7 +5,7 @@
5 5 * KnowledgeTree Community Edition
6 6 * Document Management Made Simple
7 7 * Copyright (C) 2008, 2009 KnowledgeTree Inc.
8   - *
  8 + *
9 9 *
10 10 * This program is free software; you can redistribute it and/or modify it under
11 11 * the terms of the GNU General Public License version 3 as published by the
... ... @@ -41,7 +41,8 @@ require_once(KT_LIB_DIR . '/templating/templating.inc.php');
41 41  
42 42 class RescheduleDocumentsDispatcher extends KTAdminDispatcher
43 43 {
44   - function check() {
  44 + function check()
  45 + {
45 46 $this->aBreadcrumbs[] = array(
46 47 'url' => $_SERVER['PHP_SELF'],
47 48 'name' => _kt('Reschedule all documents'),
... ... @@ -49,28 +50,34 @@ class RescheduleDocumentsDispatcher extends KTAdminDispatcher
49 50 return parent::check();
50 51 }
51 52  
52   - function do_main() {
53   -
54   - //registerTypes registers the mime types and populates the needed tables.
55   - $indexer = Indexer::get();
56   - $indexer->registerTypes();
57   -
  53 + function do_main()
  54 + {
58 55 $oTemplating =& KTTemplating::getSingleton();
59 56 $oTemplate =& $oTemplating->loadTemplate('ktcore/search2/reporting/rescheduledocuments');
60 57  
  58 + $rescheduleDone = ($_REQUEST['rescheduleDone'] == 'true') ? 'true' : 'false';
  59 + $reprocessDone = ($_REQUEST['reprocessDone'] == 'true') ? 'true' : 'false';
  60 +
61 61 if ($_REQUEST['rescheduleValue'] == 'reschedule')
62 62 {
  63 + //registerTypes registers the mime types and populates the needed tables.
  64 + $indexer = Indexer::get();
  65 + $indexer->registerTypes();
  66 +
63 67 Indexer::indexAll();
64   - $oTemplate->setData(array(
65   - 'context' => $this,
66   - 'rescheduleDone' => true
67   - ));
68   - return $oTemplate;
  68 + $rescheduleDone = 'true';
  69 + }
  70 +
  71 + if ($_REQUEST['rescheduleValue'] == 'reprocess')
  72 + {
  73 + Indexer::processAll();
  74 + $reprocessDone = 'true';
69 75 }
70 76  
71 77 $oTemplate->setData(array(
72 78 'context' => $this,
73   - 'rescheduleDone' => false
  79 + 'rescheduleDone' => $rescheduleDone,
  80 + 'reprocessDone' => $reprocessDone
74 81  
75 82 ));
76 83 return $oTemplate;
... ...
search2/indexing/indexerCore.inc.php
... ... @@ -700,6 +700,17 @@ abstract class Indexer
700 700 DBUtil::runQuery($sql);
701 701 }
702 702  
  703 + public static function processAll()
  704 + {
  705 + // Empty the queue
  706 + $sql = "DELETE FROM process_queue";
  707 + DBUtil::runQuery($sql);
  708 +
  709 + // Add all documents to the queue
  710 + $sql = "INSERT INTO process_queue(document_id, date_added) SELECT id, now() FROM documents WHERE status_id=1 and id not in (select document_id from process_queue)";
  711 + DBUtil::runQuery($sql);
  712 + }
  713 +
703 714 public static function indexFolder($folder)
704 715 {
705 716 $userid=$_SESSION['userID'];
... ...
sql/mysql/upgrade/3.7.0.2/reprocess_all.sql 0 → 100644
  1 +INSERT INTO process_queue(document_id, date_added) SELECT id, now() FROM documents WHERE status_id=1 and id not in (select document_id from process_queue);
0 2 \ No newline at end of file
... ...
templates/ktcore/search2/reporting/rescheduledocuments.smarty
... ... @@ -4,12 +4,25 @@
4 4  
5 5 <form name="rescheduleAllDocs" action="{$smarty.server.PHP_SELF}" method="POST">
6 6 <br>
7   -{if $rescheduleDone == true}
8   -<p>Documents Rescheduled</p>
9   -<p>You can view the schedule queue <a href=admin.php?kt_path_info=search/pendingdocuments>here</a></p>
  7 +<h4>{i18n}Reschedule All Documents for Indexing{/i18n}</h4>
  8 +<p class='descriptiveText'>{i18n}Schedule all documents in the repository to be indexed.{/i18n}</p>
  9 +{if $rescheduleDone == 'true'}
  10 +<p style="padding-top: 5px;">{i18n}All documents have been rescheduled for indexing.{/i18n}</p>
  11 +<p><a href=admin.php?kt_path_info=search/pendingdocuments>{i18n}View the indexing queue.{/i18n}</a></p>
  12 +{/if}
10 13 <br>
  14 +<input type="submit" name="Reschedule" value="{i18n}Reschedule All{/i18n}" onclick="document.getElementById('rescheduleValue').value='reschedule';" />
  15 +
  16 +<br><br><br>
  17 +<h4>{i18n}Reschedule All Documents for Processing{/i18n}</h4>
  18 +<p class='descriptiveText'>{i18n}Schedule all documents in the repository to be processed. Processing involves the conversion of documents into PDF format and the generation of thumbnails.{/i18n}</p>
  19 +{if $reprocessDone == 'true'}
  20 +<p style="padding-top: 5px;">{i18n}All documents have been rescheduled for processing.{/i18n}</p>
11 21 {/if}
12   -<input type="submit" name="Reschedule" value="{i18n}Reschedule All{/i18n}" />
13   -<input type="hidden" name="rescheduleValue" id="rescheduleValue" value="reschedule" />
  22 +<br>
  23 +<input type="submit" name="Reprocess" value="{i18n}Reschedule All{/i18n}" onclick="document.getElementById('rescheduleValue').value='reprocess';" />
14 24  
  25 +<input type="hidden" name="rescheduleDone" id="rescheduleDone" value="{$rescheduleDone}" />
  26 +<input type="hidden" name="reprocessDone" id="reprocessDone" value="{$reprocessDone}" />
  27 +<input type="hidden" name="rescheduleValue" id="rescheduleValue" value="reschedule" />
15 28 </form>
16 29 \ No newline at end of file
... ...