Commit 2d0c5237a5881d110cefc9dc3d1734e98fd547b5
1 parent
449fb3ff
KTS-2691
"Add the ability to enable / disable tasks within the scheduler" Fixed. Added a status flag to determine if tasks are enabled / disabled / system. Set the indexing tasks as system. KTS-1346 "Periodic deleted document expunge" Fixed. Changed the print statements to use the log. Added the expunge script to the scheduler and set as disabled. Committed by: Megan Watson Reviewed by: Conrad Vermeulen git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7720 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
4 changed files
with
27 additions
and
25 deletions
bin/expungeall.php
| ... | ... | @@ -2,37 +2,37 @@ |
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | 4 | * |
| 5 | - * $Id:$ | |
| 5 | + * $Id$ | |
| 6 | 6 | * |
| 7 | 7 | * KnowledgeTree Open Source Edition |
| 8 | 8 | * Document Management Made Simple |
| 9 | 9 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited |
| 10 | - * | |
| 10 | + * | |
| 11 | 11 | * This program is free software; you can redistribute it and/or modify it under |
| 12 | 12 | * the terms of the GNU General Public License version 3 as published by the |
| 13 | 13 | * Free Software Foundation. |
| 14 | - * | |
| 14 | + * | |
| 15 | 15 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 16 | 16 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 17 | 17 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 18 | 18 | * details. |
| 19 | - * | |
| 19 | + * | |
| 20 | 20 | * You should have received a copy of the GNU General Public License |
| 21 | 21 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 22 | - * | |
| 22 | + * | |
| 23 | 23 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, |
| 24 | 24 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. |
| 25 | - * | |
| 25 | + * | |
| 26 | 26 | * The interactive user interfaces in modified source and object code versions |
| 27 | 27 | * of this program must display Appropriate Legal Notices, as required under |
| 28 | 28 | * Section 5 of the GNU General Public License version 3. |
| 29 | - * | |
| 29 | + * | |
| 30 | 30 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 31 | 31 | * these Appropriate Legal Notices must retain the display of the "Powered by |
| 32 | - * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 32 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 33 | 33 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices |
| 34 | - * must display the words "Powered by KnowledgeTree" and retain the original | |
| 35 | - * copyright notice. | |
| 34 | + * must display the words "Powered by KnowledgeTree" and retain the original | |
| 35 | + * copyright notice. | |
| 36 | 36 | * Contributor( s): ______________________________________ |
| 37 | 37 | */ |
| 38 | 38 | |
| ... | ... | @@ -45,11 +45,11 @@ require_once('../ktapi/ktapi.inc.php'); |
| 45 | 45 | * admin=admin |
| 46 | 46 | * password=admin |
| 47 | 47 | * maximum=50 |
| 48 | - * | |
| 48 | + * | |
| 49 | 49 | * admin and password is required to expunge documents from the system. |
| 50 | - * | |
| 50 | + * | |
| 51 | 51 | * maximum is the maximum number of documents that should be expunged from the system in one run. |
| 52 | - * | |
| 52 | + * | |
| 53 | 53 | */ |
| 54 | 54 | |
| 55 | 55 | $start_time = time(); |
| ... | ... | @@ -63,12 +63,10 @@ $ktapi = new KTAPI(); |
| 63 | 63 | $session = $ktapi->start_session($user, $password); |
| 64 | 64 | if (PEAR::isError($session)) |
| 65 | 65 | { |
| 66 | - print $session->getMessage() . "\n"; | |
| 66 | + $default->log->debug('Expunge_all task: Can\'t create session: '.$session->getMessage()); | |
| 67 | 67 | return; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | -print "Expunging documents.\n(Attempting $maximum documents)\n\n"; | |
| 71 | - | |
| 72 | 70 | $sql = sprintf("SELECT id FROM documents WHERE status_id=%d LIMIT %d", DELETED, $maximum); |
| 73 | 71 | |
| 74 | 72 | $rows = DBUtil::getResultArray($sql); |
| ... | ... | @@ -76,13 +74,11 @@ $count = count($rows); |
| 76 | 74 | |
| 77 | 75 | if ($count == 0) |
| 78 | 76 | { |
| 79 | - print "Nothing to do.\n"; | |
| 77 | + $default->log->debug('Expunge_all task: Nothing to do.'); | |
| 80 | 78 | $session->logout(); |
| 81 | 79 | return; |
| 82 | 80 | } |
| 83 | 81 | |
| 84 | -print "Rows found: $count\n\n"; | |
| 85 | - | |
| 86 | 82 | foreach($rows as $row) |
| 87 | 83 | { |
| 88 | 84 | $id = $row['id']; |
| ... | ... | @@ -90,11 +86,11 @@ foreach($rows as $row) |
| 90 | 86 | $document = $ktapi->get_document_by_id($id); |
| 91 | 87 | $title = $document->get_title(); |
| 92 | 88 | |
| 93 | - print "Document ID: $id Name: '$title'\n"; | |
| 89 | + $default->log->info('Expunge_all task: Document to expunge, ID: '.$id.' Name: '.$title); | |
| 94 | 90 | $result = $document->expunge(); |
| 95 | 91 | if (PEAR::isError($result)) |
| 96 | 92 | { |
| 97 | - print $result->getMessage() . "\n"; | |
| 93 | + $default->log->error('Expunge_all task: document can\'t be expunged: '.$result->getMessage()); | |
| 98 | 94 | } |
| 99 | 95 | } |
| 100 | 96 | |
| ... | ... | @@ -102,6 +98,5 @@ $end_time = time(); |
| 102 | 98 | |
| 103 | 99 | $diff = $end_time - $start_time; |
| 104 | 100 | |
| 105 | -print "\ndone. $diff seconds.\n"; | |
| 106 | 101 | $session->logout(); |
| 107 | 102 | ?> |
| 108 | 103 | \ No newline at end of file | ... | ... |
sql/mysql/install/data.sql
No preview for this file type
sql/mysql/install/structure.sql
| ... | ... | @@ -1319,6 +1319,7 @@ CREATE TABLE `scheduler_tasks` ( |
| 1319 | 1319 | `run_time` datetime default NULL, |
| 1320 | 1320 | `previous_run_time` datetime default NULL, |
| 1321 | 1321 | `run_duration` float default NULL, |
| 1322 | + `status` ENUM('enabled', 'disabled', 'system') NOT NULL DEFAULT 'disabled', | |
| 1322 | 1323 | PRIMARY KEY (`id`), |
| 1323 | 1324 | UNIQUE KEY `task` (`task`) |
| 1324 | 1325 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ... | ... |
sql/mysql/upgrade/3.5.2/scheduler_tasks.sql
0 → 100644
| 1 | +ALTER TABLE `scheduler_tasks` ADD `status` ENUM( 'enabled', 'disabled', 'system' ) NOT NULL DEFAULT 'disabled'; | |
| 2 | + | |
| 3 | +UPDATE `scheduler_tasks` SET `status` = 'system' WHERE `task` = 'Indexing' OR `task` = 'Index Migration' OR `task` = 'Index Optimisation'; | |
| 4 | + | |
| 5 | +INSERT INTO `scheduler_tasks` VALUES (4,'Periodic Document Expunge','bin/expungeall.php','',0,'weekly','2007-10-01',NULL,0,'disabled'); | |
| 0 | 6 | \ No newline at end of file | ... | ... |