diff --git a/bin/expungeall.php b/bin/expungeall.php index f5ef25d..d93ff26 100644 --- a/bin/expungeall.php +++ b/bin/expungeall.php @@ -2,37 +2,37 @@ /** * - * $Id:$ + * $Id$ * * KnowledgeTree Open Source Edition * Document Management Made Simple * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited - * + * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License version 3 as published by the * Free Software Foundation. - * + * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * + * * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. - * + * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU General Public License version 3. - * + * * In accordance with Section 7(b) of the GNU General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by - * KnowledgeTree" logo and retain the original copyright notice. If the display of the + * KnowledgeTree" logo and retain the original copyright notice. If the display of the * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices - * must display the words "Powered by KnowledgeTree" and retain the original - * copyright notice. + * must display the words "Powered by KnowledgeTree" and retain the original + * copyright notice. * Contributor( s): ______________________________________ */ @@ -45,11 +45,11 @@ require_once('../ktapi/ktapi.inc.php'); * admin=admin * password=admin * maximum=50 - * + * * admin and password is required to expunge documents from the system. - * + * * maximum is the maximum number of documents that should be expunged from the system in one run. - * + * */ $start_time = time(); @@ -63,12 +63,10 @@ $ktapi = new KTAPI(); $session = $ktapi->start_session($user, $password); if (PEAR::isError($session)) { - print $session->getMessage() . "\n"; + $default->log->debug('Expunge_all task: Can\'t create session: '.$session->getMessage()); return; } -print "Expunging documents.\n(Attempting $maximum documents)\n\n"; - $sql = sprintf("SELECT id FROM documents WHERE status_id=%d LIMIT %d", DELETED, $maximum); $rows = DBUtil::getResultArray($sql); @@ -76,13 +74,11 @@ $count = count($rows); if ($count == 0) { - print "Nothing to do.\n"; + $default->log->debug('Expunge_all task: Nothing to do.'); $session->logout(); return; } -print "Rows found: $count\n\n"; - foreach($rows as $row) { $id = $row['id']; @@ -90,11 +86,11 @@ foreach($rows as $row) $document = $ktapi->get_document_by_id($id); $title = $document->get_title(); - print "Document ID: $id Name: '$title'\n"; + $default->log->info('Expunge_all task: Document to expunge, ID: '.$id.' Name: '.$title); $result = $document->expunge(); if (PEAR::isError($result)) { - print $result->getMessage() . "\n"; + $default->log->error('Expunge_all task: document can\'t be expunged: '.$result->getMessage()); } } @@ -102,6 +98,5 @@ $end_time = time(); $diff = $end_time - $start_time; -print "\ndone. $diff seconds.\n"; $session->logout(); ?> \ No newline at end of file diff --git a/sql/mysql/install/data.sql b/sql/mysql/install/data.sql index ab9648a..98ba264 100644 --- a/sql/mysql/install/data.sql +++ b/sql/mysql/install/data.sql @@ -795,9 +795,10 @@ UNLOCK TABLES; LOCK TABLES `scheduler_tasks` WRITE; /*!40000 ALTER TABLE `scheduler_tasks` DISABLE KEYS */; INSERT INTO `scheduler_tasks` VALUES -(1,'Indexing','search2/indexing/bin/cronIndexer.php','',0,'1min','2007-10-01',NULL,0), -(2,'Index Migration','search2/indexing/bin/cronMigration.php','',0,'5mins','2007-10-01',NULL,0), -(3,'Index Optimisation','search2/indexing/bin/optimise.php','',0,'weekly','2007-10-01',NULL,0); +(1,'Indexing','search2/indexing/bin/cronIndexer.php','',0,'1min','2007-10-01',NULL,0,'system'), +(2,'Index Migration','search2/indexing/bin/cronMigration.php','',0,'5mins','2007-10-01',NULL,0,'system'), +(3,'Index Optimisation','search2/indexing/bin/optimise.php','',0,'weekly','2007-10-01',NULL,0,'system'), +(4,'Periodic Document Expunge','bin/expungeall.php','',0,'weekly','2007-10-01',NULL,0,'disabled'); /*!40000 ALTER TABLE `scheduler_tasks` ENABLE KEYS */; UNLOCK TABLES; diff --git a/sql/mysql/install/structure.sql b/sql/mysql/install/structure.sql index a153a96..d8af55d 100644 --- a/sql/mysql/install/structure.sql +++ b/sql/mysql/install/structure.sql @@ -1319,6 +1319,7 @@ CREATE TABLE `scheduler_tasks` ( `run_time` datetime default NULL, `previous_run_time` datetime default NULL, `run_duration` float default NULL, + `status` ENUM('enabled', 'disabled', 'system') NOT NULL DEFAULT 'disabled', PRIMARY KEY (`id`), UNIQUE KEY `task` (`task`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/sql/mysql/upgrade/3.5.2/scheduler_tasks.sql b/sql/mysql/upgrade/3.5.2/scheduler_tasks.sql new file mode 100644 index 0000000..87af221 --- /dev/null +++ b/sql/mysql/upgrade/3.5.2/scheduler_tasks.sql @@ -0,0 +1,5 @@ +ALTER TABLE `scheduler_tasks` ADD `status` ENUM( 'enabled', 'disabled', 'system' ) NOT NULL DEFAULT 'disabled'; + +UPDATE `scheduler_tasks` SET `status` = 'system' WHERE `task` = 'Indexing' OR `task` = 'Index Migration' OR `task` = 'Index Optimisation'; + +INSERT INTO `scheduler_tasks` VALUES (4,'Periodic Document Expunge','bin/expungeall.php','',0,'weekly','2007-10-01',NULL,0,'disabled'); \ No newline at end of file