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/bin/scheduler.php b/bin/scheduler.php
index e51162e..5101cd5 100644
--- a/bin/scheduler.php
+++ b/bin/scheduler.php
@@ -96,7 +96,7 @@ function updateTask($aFieldValues, $iId) {
function getTaskList() {
$now = date('Y-m-d H:i:s'); //time();
- $query = "SELECT * FROM scheduler_tasks WHERE is_complete = 0 AND run_time < '{$now}'";
+ $query = "SELECT * FROM scheduler_tasks WHERE is_complete = 0 AND run_time < '{$now}' AND status != 'disabled'";
$result = DBUtil::getResultArray($query);
diff --git a/docs/VERSION.txt b/docs/VERSION.txt
index 1545d96..87ce492 100644
--- a/docs/VERSION.txt
+++ b/docs/VERSION.txt
@@ -1 +1 @@
-3.5.0
+3.5.2
diff --git a/plugins/ktcore/KTWorkflowTriggers.inc.php b/plugins/ktcore/KTWorkflowTriggers.inc.php
index f6450d4..9c6eb6b 100644
--- a/plugins/ktcore/KTWorkflowTriggers.inc.php
+++ b/plugins/ktcore/KTWorkflowTriggers.inc.php
@@ -514,6 +514,15 @@ class BaseCopyActionTrigger extends KTWorkflowTrigger {
$fFolderId = KTUtil::arrayGet($_REQUEST, 'fFolderId', KTUtil::arrayGet($this->aConfig, 'folder_id', 1));
+ $oFolder = Folder::get($fFolderId);
+ if(PEAR::isError($oFolder))
+ {
+ $iRoot = 1;
+ $oFolder = Folder::get($iRoot);
+ $fFolderId = 1;
+
+ }
+
$collection->setOptions($aOptions);
$collection->setQueryObject(new BrowseQuery($fFolderId, $this->oUser));
$collection->setColumnOptions('ktcore.columns.singleselection', array(
@@ -527,7 +536,7 @@ class BaseCopyActionTrigger extends KTWorkflowTrigger {
'folder_link' => $aOptions['result_url'],
));
- $oFolder = Folder::get($fFolderId);
+
$aBreadcrumbs = array();
$folder_path_names = $oFolder->getPathArray();
$folder_path_ids = explode(',', $oFolder->getParentFolderIds());
diff --git a/plugins/ktcore/scheduler/scheduler.php b/plugins/ktcore/scheduler/scheduler.php
index 8f379c8..78ff4a0 100644
--- a/plugins/ktcore/scheduler/scheduler.php
+++ b/plugins/ktcore/scheduler/scheduler.php
@@ -1,36 +1,36 @@
.
- *
+ *
* 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): ______________________________________
*
*/
@@ -47,7 +47,8 @@ class Scheduler
var $aParams = '';
var $sFreq = 'daily';
var $iStartTime = '';
-
+ var $sStatus = 'disabled';
+
/**
* Constructor function - set the name of the task
*/
@@ -56,14 +57,14 @@ class Scheduler
$this->sFreq = 'daily';
$this->iStartTime = time();
}
-
+
/**
* Set the name of the task
*/
function setTaskName($sName) {
$this->sName = $sName;
}
-
+
/**
* Set the path to the script from the KT base path
* For example: "/var/tasks/script.php" or "/bin/script.php"
@@ -71,14 +72,14 @@ class Scheduler
function setScriptPath($sPath) {
$this->sPath = $sPath;
}
-
+
/**
* Add a parameter pair to pass to the script
*/
function addParameter($param, $value){
$this->aParams[$param] = $value;
}
-
+
/**
* Set the frequency with which the task must be run
* Frequencies are: daily, weekly, monthly, hourly, half_hourly, quarter_hourly, 10mins, 5mins and once
@@ -86,16 +87,34 @@ class Scheduler
function setFrequency($sFrequency) {
$this->sFreq = $sFrequency;
}
-
+
/**
- * Set the time at which the task should first be run or if it is a once off, the time to run it.
+ * Set the time at which the task should first be run or if it is a once off, the time to run it.
* Time should be in datetime format.
- * By default the time is set to now.
+ * By default the time is set to now.
*/
function setFirstRunTime($iTime) {
$this->iStartTime = !empty($iTime) ? $iTime : date('Y-m-d H:i:s');
}
-
+
+ /**
+ * Set the task as enabled or disabled. If the task is already set as a system task, then ignore.
+ */
+ function setEnabled($bStatus = FALSE) {
+ if($bStatus && $this->sStatus != 'system'){
+ $this->sStatus = 'enabled';
+ }
+ }
+
+ /**
+ * Set the task as a system task, this cannot be enabled or disabled.
+ */
+ function setAsSystemTask($bSystem = FALSE) {
+ if($bSystem){
+ $this->sStatus = 'system';
+ }
+ }
+
/**
* Create a script - write it to the filesystem.
* Scripts are saved in the KT_DIR."/var/tasks/" directory.
@@ -105,33 +124,33 @@ class Scheduler
// Path to scripts
$ktPath = '/var/tasks/';
$path = KT_DIR.$ktPath;
-
+
if(!is_dir($path)){
mkdir($path, '0755');
}
-
+
// Create script file
$sName = str_replace(' ', '_', $this->sName);
$sName = str_replace('', "'", $sName);
$sName = str_replace('', "&", $sName);
$sFileName = $sName.'_'.mt_rand(1, 999).'.php';
-
+
while(file_exists($path.$sFileName)){
$sFileName = $sTask.'_'.mt_rand(1, 9999).'.php';
}
-
+
$fp = fopen($path.$sFileName, 'wb');
fwrite($fp, $sScript);
fclose($fp);
-
+
$this->sPath = $ktPath.$sFileName;
}
-
+
/**
* Register the task in the scheduler
*/
function registerTask(){
- schedulerUtil::registerTask($this->sName, $this->sPath, $this->aParams, $this->sFreq, $this->iStartTime);
+ schedulerUtil::registerTask($this->sName, $this->sPath, $this->aParams, $this->sFreq, $this->iStartTime, $this->sStatus);
}
}
?>
diff --git a/plugins/ktcore/scheduler/schedulerDashlet.php b/plugins/ktcore/scheduler/schedulerDashlet.php
index 3329acb..3fa4aab 100644
--- a/plugins/ktcore/scheduler/schedulerDashlet.php
+++ b/plugins/ktcore/scheduler/schedulerDashlet.php
@@ -5,32 +5,32 @@
* 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): ______________________________________
*
*/
@@ -42,7 +42,7 @@ class schedulerDashlet extends KTBaseDashlet {
var $oUser;
var $sClass = "ktError";
var $aTimes = array();
-
+
function schedulerDashlet() {
$this->sTitle = _kt('Scheduler');
}
@@ -55,7 +55,7 @@ class schedulerDashlet extends KTBaseDashlet {
}
return false;
}
-
+
/**
* Get the last and next run times for the scheduler.
* @return bool true if scheduler is overdue
@@ -63,26 +63,26 @@ class schedulerDashlet extends KTBaseDashlet {
function checkOverDue() {
$this->aTimes = schedulerUtil::checkLastRunTime();
$sNextRunTime = $this->aTimes['nextruntime'];
-
+
$iNow = time();
$iNext = strtotime($sNextRunTime);
-
+
if($iNow > $iNext){
$iDif = $iNow - $iNext;
-
+
// if it hasn't run for a whole day then display dashlet alert.
if($iDif > 60*60*24) {
return true;
}
}
-
+
return false;
}
-
+
/**
* Calculate the time difference in days/hours/minutes
*/
- function renderTime($iDif, $iUnit, $iRemainder, $sUnit, $sRemainder) {
+ function renderTime($iDif, $iUnit, $iRemainder, $sUnit, $sRemainder) {
// days
$iTime = round($iDif / $iUnit, 2);
$aRemainder = explode('.', $iTime);
@@ -95,48 +95,48 @@ class schedulerDashlet extends KTBaseDashlet {
$time = floor($iTime).' '.$sUnit.$remainder;
return $time;
}
-
+
/**
* Get the last and next run times for the scheduler
*/
function getRunTimes() {
$bDue = FALSE;
-
+
// Check when the scheduler last ran and when the next task run time should be
$aTimes = $this->aTimes;
- $sLastRunTime = $aTimes['lastruntime'];
+ $sLastRunTime = $aTimes['lastruntime'];
$sNextRunTime = $aTimes['nextruntime'];
-
+
// Check if scheduler has missed the last run
$iNow = time();
$iNext = strtotime($sNextRunTime);
-
+
if($iNow > $iNext){
$bDue = TRUE;
$iDif = $iNow - $iNext;
}else{
$iDif = $iNext - $iNow;
}
-
+
$time = $iDif.' '._kt('seconds'); $remainder = '';
// Get the difference in easy units of time
- if($iDif >= 60*60*24*7){
+ if($iDif >= 60*60*24*7){
// weeks
$time = ' '.schedulerDashlet::renderTime($iDif, 60*60*24*7, 7, _kt('week(s)'), _kt('day(s)'));
- }else if($iDif >= 60*60*24){
- // days
+ }else if($iDif >= 60*60*24){
+ // days
$time = ' '.schedulerDashlet::renderTime($iDif, 60*60*24, 24, _kt('day(s)'), _kt('hour(s)'));
- }else if($iDif >= 60*60){
+ }else if($iDif >= 60*60){
// hours
$time = ' '.schedulerDashlet::renderTime($iDif, 60*60, 60, _kt('hour(s)'), _kt('minute(s)'));
- }else if($iDif >= 60){
+ }else if($iDif >= 60){
// minutes
$time = ' '.schedulerDashlet::renderTime($iDif, 60, 60, _kt('minute(s)'), _kt('second(s)'));
}
-
+
return array('lasttime' => $sLastRunTime, 'timedif' => $time, 'due' => $bDue);
}
-
+
function render() {
$bWin = false;
if(OS_WINDOWS){
@@ -146,11 +146,11 @@ class schedulerDashlet extends KTBaseDashlet {
$sLastTime = $aTimes['lasttime'];
$sTimeDif = $aTimes['timedif'];
$bDue = $aTimes['due'];
-
-
+
+
$oKTConfig =& KTConfig::getSingleton();
$rootUrl = $oKTConfig->get("rootUrl");
-
+
if($oKTConfig->get("ui/morphEnabled") == '1') {
$sImg = $rootUrl.'/skins/kts_'.$oKTConfig->get("ui/morphTo");
}else{
@@ -158,9 +158,9 @@ class schedulerDashlet extends KTBaseDashlet {
}
$sImgPlus = $sImg.'/bullet_toggle_plus.png';
$sImgMinus = $sImg.'/bullet_toggle_minus.png';
-
+
$sPath = KT_DIR.'/bin/scheduler.php';
- $sOnClick = " var cron = document.getElementById('cronguide');
+ $sOnClick = " var cron = document.getElementById('cronguide');
var icon = document.getElementById('scheduler_icon');
if(cron.style.visibility == 'hidden'){
cron.style.visibility = 'visible'; cron.style.display = 'block';
@@ -169,9 +169,10 @@ class schedulerDashlet extends KTBaseDashlet {
cron.style.visibility = 'hidden'; cron.style.display = 'none';
icon.src = '{$sImgPlus}';
}";
-
+
$sAdmin = KTUtil::ktLink('admin.php', 'misc/scheduler');
-
+ $sAdminLink = ""._kt('Administration page').'';
+
$oTemplating =& KTTemplating::getSingleton();
$oTemplate = $oTemplating->loadTemplate('ktcore/dashlets/scheduler');
@@ -181,7 +182,7 @@ class schedulerDashlet extends KTBaseDashlet {
'isDue' => $bDue,
'bWin' => $bWin,
'sPath' => $sPath,
- 'sAdmin' => $sAdmin,
+ 'sAdminLink' => $sAdminLink,
'sImg' => $sImgPlus,
'onClick' => $sOnClick,
);
diff --git a/plugins/ktcore/scheduler/schedulerEntity.php b/plugins/ktcore/scheduler/schedulerEntity.php
index 86824b7..fb60fbe 100644
--- a/plugins/ktcore/scheduler/schedulerEntity.php
+++ b/plugins/ktcore/scheduler/schedulerEntity.php
@@ -52,6 +52,7 @@ class schedulerEntity extends KTEntity
var $iRun_time;
var $iPrevious_run_time;
var $iRun_duration;
+ var $sStatus;
var $_aFieldToSelect = array(
'iId' => 'id',
@@ -62,7 +63,8 @@ class schedulerEntity extends KTEntity
'iFrequency' => 'frequency',
'iRun_time' => 'run_time',
'iPrevious_run_time' => 'previous_run_time',
- 'iRun_duration' => 'run_duration'
+ 'iRun_duration' => 'run_duration',
+ 'sStatus' => 'status'
);
function _table () {
@@ -78,6 +80,7 @@ class schedulerEntity extends KTEntity
function getParams() { return $this->sScript_params; }
function getIsComplete() { return $this->bIs_complete; }
function getFrequency() { return $this->iFrequency; }
+ function getStatus() { return $this->sStatus; }
function getFrequencyByLang() {
$aFrequencies = array(
@@ -117,6 +120,7 @@ class schedulerEntity extends KTEntity
function setRunTime($sValue) { return $this->iRun_time = date('Y-m-d H:i:s', $sValue); }
function setPrevious($sValue) { return $this->iPrevious_run_time = date('Y-m-d H:i:s', $sValue); }
function setRunDuration($sValue) { return $this->iRun_duration = $sValue; }
+ function setStatus($sValue) { return $this->sStatus = $sValue; }
function get($iId) {
return KTEntityUtil::get('schedulerEntity', $iId);
@@ -124,10 +128,11 @@ class schedulerEntity extends KTEntity
function getTasksToRun() {
$aOptions = array('multi' => true);
- $aFields = array('is_complete', 'run_time');
+ $aFields = array('is_complete', 'run_time', 'status');
$aValues = array();
$aValues[] = array('type' => 'equals', 'value' => '0');
$aValues[] = array('type' => 'before', 'value' => time());
+ $aValues[] = array('type' => 'nequals', 'value' => 'disabled');
return KTEntityUtil::getBy('schedulerEntity', $aFields, $aValues, $aOptions);
}
@@ -139,9 +144,10 @@ class schedulerEntity extends KTEntity
function getLastRunTime($date) {
$aOptions = array('multi' => true, 'orderby' => 'previous_run_time DESC');
- $aFields = array('previous_run_time');
+ $aFields = array('previous_run_time', 'status');
$aValues = array();
$aValues[] = array('type' => 'before', 'value' => $date);
+ $aValues[] = array('type' => 'nequals', 'value' => 'disabled');
return KTEntityUtil::getBy('schedulerEntity', $aFields, $aValues, $aOptions);
}
@@ -175,11 +181,40 @@ class schedulerEntity extends KTEntity
}
/**
+ * Display the task name. If the task is disabled then grey it out.
+ *
+ */
+ function getTaskDiv() {
+ $sId = $this->getId();
+ $sStatus = $this->getStatus();
+
+ $sDiv = "' : 'class="descriptiveText">';
+ $sDiv .= $this->getTask().'';
+ return $sDiv;
+ }
+
+ function getFreqDiv() {
+ $sId = $this->getId();
+ $sStatus = $this->getStatus();
+ $sFreqs = $this->getFrequencyByLang();
+
+ $sLink = "' : '>';
+ $sLink .= "$sFreqs
";
+ return $sLink;
+ }
+
+ /**
* Get a link to alter the frequency of a task
*/
function getAlterFreqLink() {
$sId = $this->getId();
- $sLink = ""._kt('Alter frequency')."";
+ $sStatus = $this->getStatus();
+
+ $sLink = "' : '>';
+ $sLink .= _kt('Alter frequency')."";
return $sLink;
}
@@ -188,9 +223,33 @@ class schedulerEntity extends KTEntity
*/
function getRunNowLink() {
$sId = $this->getId();
+ $sStatus = $this->getStatus();
$sUrl = KTUtil::ktLink('admin.php', 'misc/scheduler', 'action=updateRunTime');
- $sLink = ""._kt('Run on next iteration')."";
+
+ $sLink = "' : '>';
+ $sLink .= _kt('Run on next iteration')."";
+ return $sLink;
+ }
+
+ /**
+ * Run the task on the next iteration
+ */
+ function getStatusLink() {
+ $sId = $this->getId();
+ $sStatus = $this->getStatus();
+ if($sStatus == 'system'){
+ return '';
+ }
+
+ $sDisableText = _kt('Disable task');
+ $sEnableText = _kt('Enable task');
+
+ $sLinkText = ($sStatus == 'enabled') ? $sDisableText : $sEnableText;
+ $sUrl = KTUtil::ktLink('admin.php', 'misc/scheduler', 'action=updateStatus');
+ $sLink = "{$sLinkText}";
return $sLink;
}
}
-?>
+?>
\ No newline at end of file
diff --git a/plugins/ktcore/scheduler/schedulerUtil.php b/plugins/ktcore/scheduler/schedulerUtil.php
index c1feef3..5839787 100644
--- a/plugins/ktcore/scheduler/schedulerUtil.php
+++ b/plugins/ktcore/scheduler/schedulerUtil.php
@@ -77,7 +77,7 @@ class schedulerUtil extends KTUtil
/**
* Method to register a task in the schedule
*/
- function registerTask($sTask, $sUrl, $aParams, $sFreq, $iStartTime = NULL) {
+ function registerTask($sTask, $sUrl, $aParams, $sFreq, $iStartTime = NULL, $sStatus = 'disabled') {
// Run task on next iteration if no start time given
$iStartTime = (!empty($iStartTime)) ? strtotime($iStartTime) : time();
@@ -101,6 +101,7 @@ class schedulerUtil extends KTUtil
$aTask['run_time'] = $dNextTime;
$aTask['previous_run_time'] = $dStartTime;
$aTask['run_duration'] = '0';
+ $sTask['status'] = $sStatus;
$oEntity = schedulerEntity::createFromArray($aTask);
if (PEAR::isError($oEntity)){
@@ -127,6 +128,7 @@ class schedulerUtil extends KTUtil
$aTask['is_complete'] = '0';
$aTask['run_time'] = date('Y-m-d H:i:s');
$aTask['run_duration'] = '0';
+ $aTask['status'] = 'enabled';
$oEntity = schedulerEntity::createFromArray($aTask);
if (PEAR::isError($oEntity)){
@@ -232,6 +234,29 @@ class schedulerUtil extends KTUtil
}
/**
+ * Toggle whether a task is enabled or disabled. If its a system task, then ignore.
+ */
+ function toggleStatus($id) {
+ $oScheduler = schedulerEntity::get($id);
+
+ if (PEAR::isError($oScheduler)){
+ return _kt('Object can\'t be created');
+ }
+
+ $sStatus = $oScheduler->getStatus();
+
+ if($sStatus == 'system'){
+ // ignore
+ return $sStatus;
+ }
+
+ $sNewStatus = ($sStatus == 'enabled') ? 'disabled' : 'enabled';
+ $oScheduler->setStatus($sNewStatus);
+ $oScheduler->update();
+ return $sNewStatus;
+ }
+
+ /**
* Check the last run time of the scheduler
*/
function checkLastRunTime() {
diff --git a/plugins/ktcore/scheduler/taskScheduler.php b/plugins/ktcore/scheduler/taskScheduler.php
index dec074b..61a31a9 100644
--- a/plugins/ktcore/scheduler/taskScheduler.php
+++ b/plugins/ktcore/scheduler/taskScheduler.php
@@ -120,5 +120,13 @@ class manageSchedulerDispatcher extends KTAdminDispatcher
schedulerUtil::updateRunTime($id, $iNextTime);
return $iNextTime;
}
+
+ /**
+ * Toggle the enable/disable on the task
+ */
+ function do_updateStatus() {
+ $fId = schedulerUtil::arrayGet($_REQUEST, 'fId');
+ schedulerUtil::toggleStatus($fId);
+ }
}
?>
diff --git a/plugins/ktstandard/PDFGeneratorAction.php b/plugins/ktstandard/PDFGeneratorAction.php
index 98210f3..42d6188 100644
--- a/plugins/ktstandard/PDFGeneratorAction.php
+++ b/plugins/ktstandard/PDFGeneratorAction.php
@@ -2,35 +2,29 @@
/**
* $Id$
*
- * KnowledgeTree Open Source Edition
- * Document Management Made Simple
- * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited
+ * The contents of this file are subject to the KnowledgeTree Public
+ * License Version 1.1.2 ("License"); You may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.knowledgetree.com/KPL
*
- * 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.
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ * See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * All copies of the Covered Code must include on each user interface screen:
+ * (i) the "Powered by KnowledgeTree" logo and
+ * (ii) the KnowledgeTree copyright notice
+ * in the same form as they appear in the distribution. See the License for
+ * requirements.
*
- * 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.
+ * The Original Code is: KnowledgeTree Open Source
*
- * 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
- * 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.
+ * The Initial Developer of the Original Code is The Jam Warehouse Software
+ * (Pty) Ltd, trading as KnowledgeTree.
+ * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright
+ * (C) 2007 The Jam Warehouse Software (Pty) Ltd;
+ * All Rights Reserved.
* Contributor( s): ______________________________________
*
*/
@@ -51,8 +45,8 @@ class PDFGeneratorAction extends KTDocumentAction {
var $sDisplayName = 'Generate PDF';
// Note: 'asc' below seems to be a catchall for plain text docs.
// 'htm' and 'html' should work but are not so have been removed for now.
- var $aAcceptedMimeTypes = array('doc', 'ods', 'odt', 'ott', 'txt', 'rtf', 'sxw', 'stw',
- // 'html', 'htm',
+ var $aAcceptedMimeTypes = array('doc', 'ods', 'odt', 'ott', 'txt', 'rtf', 'sxw', 'stw',
+ // 'html', 'htm',
'xml' , 'pdb', 'psw', 'ods', 'ots', 'sxc',
'stc', 'dif', 'dbf', 'xls', 'xlt', 'slk', 'csv', 'pxl',
'odp', 'otp', 'sxi', 'sti', 'ppt', 'pot', 'sxd', 'odg',
@@ -62,7 +56,7 @@ class PDFGeneratorAction extends KTDocumentAction {
// We need to handle Windows differently - as usual ;)
if (substr( PHP_OS, 0, 3) == 'WIN') {
$cmdpath = KT_DIR . "/../openoffice/openoffice/program/python.bat";
- $cmdpath = str_replace( '/','\\',$cmdpath);
+ $cmdpath = str_replace( '/','\\',$cmdpath);
} else {
$cmdpath = "../openoffice/program/python";
}
@@ -75,9 +69,8 @@ class PDFGeneratorAction extends KTDocumentAction {
return _kt('Generate PDF') . " $this->oDocument->getId(), "action" => "pdfdownload") ) . "\"
";
}
}
- return _kt('Generate PDF');
}
- return '';
+ return 'PDF Generator';
}
function form_main() {
@@ -123,7 +116,7 @@ class PDFGeneratorAction extends KTDocumentAction {
$this->do_pdfdownload();
}
redirect(KTUtil::ktLink( 'action.php', 'ktstandard.pdf.generate', array( "fDocumentId" => $this->oDocument->getId() ) ) );
- exit(0);
+ exit(0);
}
function do_main() {
@@ -168,7 +161,7 @@ class PDFGeneratorAction extends KTDocumentAction {
/**
* Method for downloading the document as a pdf.
*
- * @return true on success else false
+ * @return true on success else false
*/
function do_pdfdownload() {
@@ -188,7 +181,7 @@ class PDFGeneratorAction extends KTDocumentAction {
if (substr( PHP_OS, 0, 3) == 'WIN') {
$cmd = "\"" . KT_DIR . "/../openoffice/openoffice/program/python.bat\" \"". KT_DIR . "/bin/openoffice/pdfgen.py\" \"" . $sPath . "\" \"" . $sTempFilename . "\"";
- $cmd = str_replace( '/','\\',$cmd);
+ $cmd = str_replace( '/','\\',$cmd);
// TODO: Check for more errors here
// SECURTIY: Ensure $sPath and $sTempFilename are safe or they could be used to excecute arbitrary commands!
@@ -211,7 +204,7 @@ class PDFGeneratorAction extends KTDocumentAction {
}
- // Check the tempfile exists and the python script did not return anything (which would indicate an error)
+ // Check the tempfile exists and the python script did not return anything (which would indicate an error)
if (file_exists($sTempFilename) && $res == '') {
$sUrlEncodedFileName = substr($oDocument->getFileName(), 0, strrpos($oDocument->getFileName(), '.') );
@@ -231,7 +224,7 @@ class PDFGeneratorAction extends KTDocumentAction {
// HTTP/1.0
// header("Pragma: no-cache"); // Don't send this header! It breaks IE.
-
+
// Get a filelike object and send it to the browser
$oFile = new KTFSFileLike($sTempFilename);
KTFileLikeUtil::send_contents($oFile);
@@ -239,23 +232,23 @@ class PDFGeneratorAction extends KTDocumentAction {
unlink($sTempFilename);
// Create the document transaction
- $oDocumentTransaction = new DocumentTransaction($oDocument, 'Document downloaded as PDF', 'ktcore.transactions.download', $aOptions);
+ $oDocumentTransaction = & new DocumentTransaction($oDocument, 'Document downloaded as PDF', 'ktcore.transactions.download', $aOptions);
$oDocumentTransaction->create();
// Just stop here - the content has already been sent.
- exit(0);
+ exit(0);
} else {
// Set the error messsage and redirect to view document
- $this->addErrorMessage(_kt('An error occurred generating the PDF - please contact the system administrator. ' . $res));
+ $this->addErrorMessage(_kt('An error occurred generating the PDF - please contact the system administrator.
' . $res));
redirect(generateControllerLink('viewDocument',sprintf(_kt('fDocumentId=%d'),$oDocument->getId())));
- exit(0);
+ exit(0);
}
} else {
// Set the error messsage and redirect to view document
- $this->addErrorMessage(_kt('An error occurred generating the PDF - please contact the system administrator. The path to the document did not exist.'));
+ $this->addErrorMessage(_kt('An error occurred generating the PDF - please contact the system administrator.
The path to the document did not exist.'));
redirect(generateControllerLink('viewDocument',sprintf(_kt('fDocumentId=%d'),$oDocument->getId())));
- exit(0);
+ exit(0);
}
diff --git a/plugins/rssplugin/RSSDocumentLinkAction.php b/plugins/rssplugin/RSSDocumentLinkAction.php
index 829f4d9..66df51d 100644
--- a/plugins/rssplugin/RSSDocumentLinkAction.php
+++ b/plugins/rssplugin/RSSDocumentLinkAction.php
@@ -1,36 +1,28 @@
.
- *
- * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
- * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com.
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ * See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * All copies of the Covered Code must include on each user interface screen:
+ * (i) the "Powered by KnowledgeTree" logo and
+ * (ii) the KnowledgeTree copyright notice
+ * in the same form as they appear in the distribution. See the License for
+ * requirements.
*
- * 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.
+ * The Original Code is: KnowledgeTree Open Source
*
- * 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
- * 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.
+ * The Initial Developer of the Original Code is The Jam Warehouse Software
+ * (Pty) Ltd, trading as KnowledgeTree.
+ * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright
+ * (C) 2007 The Jam Warehouse Software (Pty) Ltd;
+ * All Rights Reserved.
* Contributor( s): ______________________________________
*
*/
@@ -57,7 +49,7 @@ class RSSDocumentLinkAction extends KTDocumentAction {
// get document id
if(!isset($oDocument)){
- return _kt('RSS');
+ return 'RSS';
}
$iFId = $oDocument->getID();
diff --git a/resources/js/scheduler.js b/resources/js/scheduler.js
index c0e3111..3e9f89e 100644
--- a/resources/js/scheduler.js
+++ b/resources/js/scheduler.js
@@ -28,6 +28,38 @@ var runOnNext = function(fId, sUrl) {
var transaction = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, "fId="+fId);
}
+//
+var toggleStatus = function(fId, sUrl, sDisableText, sEnableText) {
+
+ var statusLink = document.getElementById('statusLink'+fId);
+ var freqLink = document.getElementById('freqLink'+fId);
+ var runnowLink = document.getElementById('runnowLink'+fId);
+ var freqDrop = document.getElementById('freqDrop'+fId);
+ var fontClass = document.getElementById('font'+fId);
+ var freqDiv = document.getElementById('div'+fId);
+
+ var callback = {
+ success: function(o) {
+ if(statusLink.innerHTML == sDisableText){
+ statusLink.innerHTML = sEnableText;
+ freqLink.style.visibility = "hidden";
+ runnowLink.style.visibility = "hidden";
+ freqDrop.style.visibility = "hidden";
+ fontClass.className = 'descriptiveText';
+ freqDiv.style.display = "none";
+ }else{
+ statusLink.innerHTML = sDisableText;
+ freqLink.style.visibility = "visible";
+ runnowLink.style.visibility = "visible";
+ freqDrop.style.visibility = "visible";
+ freqDiv.style.display = "block";
+ fontClass.className = '';
+ }
+ }
+ }
+ var transaction = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, "fId="+fId);
+}
+
var showFrequencyDiv = function(fId) {
var formDiv = document.getElementById('formDiv');
var fInput = document.getElementById('fId');
diff --git a/sql/mysql/install/data.sql b/sql/mysql/install/data.sql
index ab9648a..c7a23cf 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;
@@ -854,7 +855,7 @@ UNLOCK TABLES;
LOCK TABLES `system_settings` WRITE;
/*!40000 ALTER TABLE `system_settings` DISABLE KEYS */;
-INSERT INTO `system_settings` VALUES (1,'lastIndexUpdate','0'),(2,'knowledgeTreeVersion','3.5'),(3,'databaseVersion','3.5.0');
+INSERT INTO `system_settings` VALUES (1,'lastIndexUpdate','0'),(2,'knowledgeTreeVersion','3.5.2'),(3,'databaseVersion','3.5.2');
/*!40000 ALTER TABLE `system_settings` 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/templates/ktcore/dashlets/scheduler.smarty b/templates/ktcore/dashlets/scheduler.smarty
index f166fa9..34a69bb 100644
--- a/templates/ktcore/dashlets/scheduler.smarty
+++ b/templates/ktcore/dashlets/scheduler.smarty
@@ -5,7 +5,7 @@
{else}
{i18n}No tasks have been run yet.{/i18n}
{/if}
- Administration page
+ {i18n arg_link=$sAdminLink}This can be configured via the #link#.{/i18n}
{if !$lasttime}
diff --git a/templates/ktcore/scheduler.smarty b/templates/ktcore/scheduler.smarty
index aca962c..2a5d4dc 100644
--- a/templates/ktcore/scheduler.smarty
+++ b/templates/ktcore/scheduler.smarty
@@ -28,15 +28,13 @@
|
- {$i++}
+ {$i++}
|
- {$task->getTask()}
+ {$task->getTaskDiv()}
|
-
-
- {$task->getFrequencyByLang()}
-
+ |
+ {$task->getFreqDiv()}
|
@@ -49,11 +47,11 @@
{$task->getPrevious(TRUE)}
|
-
+ |
{$task->getRunDuration()}
|
- {$task->getAlterFreqLink()} {$task->getRunNowLink()}
+ {$task->getAlterFreqLink()} {$task->getRunNowLink()} {$task->getStatusLink()}
|
@@ -70,7 +68,7 @@