diff --git a/bin/recreateIndexes.php b/bin/recreateIndexes.php index 445b803..add01cb 100644 --- a/bin/recreateIndexes.php +++ b/bin/recreateIndexes.php @@ -77,6 +77,7 @@ class IndexRecreator var $primary; var $globalstart; var $start; + var $tables; function microtimeFloat() { @@ -257,7 +258,11 @@ class IndexRecreator $this->addForeignKey('metadata_lookup_tree','document_field_id', 'document_fields','id'); // $this->addForeignKey('metadata_lookup_tree','metadata_lookup_tree_parent', '??','id'); - $this->addForeignKey('mime_types','mime_document_id','mime_documents','id'); + $this->addForeignKey('mime_types','mime_document_id','mime_documents','id', 'set null', 'set null'); + $this->addForeignKey('mime_types','extractor_id','mime_extractors','id', 'set null', 'set null'); + + $this->addForeignKey('mime_document_mapping','mime_type_id','mime_types','id'); + $this->addForeignKey('mime_document_mapping','mime_document_id','mime_documents','id'); $this->addForeignKey('news','image_mime_type_id','mime_types','id'); @@ -398,6 +403,13 @@ class IndexRecreator //$this->addIndex('document_types_lookup','disabled'); ? used $this->addIndex('documents','created'); + $this->addIndex('documents','modified'); + $this->addIndex('documents','full_path','','(255)'); + $this->addIndex('documents','immutable'); + $this->addIndex('documents','checkedout'); + + $this->addIndex('document_content_version','filename','','(255)'); + $this->addIndex('document_content_version','size'); $this->addIndex('field_behaviour_options',array('behaviour_id','field_id')); @@ -516,20 +528,22 @@ class IndexRecreator $this->_exec($sql); } - function addIndex($table, $fields, $type='') + function addIndex($table, $fields, $type='', $extra='') { + if (!in_array($table, $this->tables)) return; + if (!is_array($fields)) $fields = array($fields); $index = implode('_', $fields); //$index = str_replace('_id','',$index); $fields = implode(',',$fields); - $sql = "alter table $table add $type index $index ($fields) "; + $sql = "alter table $table add $type index $index ($fields$extra) "; $this->_exec($sql); } function addForeignKey($table, $field, $othertable, $otherfield, $ondelete='cascade', $onupdate='cascade') { - if (!in_array($table, $this->tables)) continue; - if (!in_array($othertable, $this->tables)) continue; + if (!in_array($table, $this->tables)) return; + if (!in_array($othertable, $this->tables)) return; $sql = "alter table $table add foreign key ($field) references $othertable ($otherfield) "; if ($ondelete != '') @@ -594,6 +608,8 @@ class IndexRecreator $this->addPrimaryKey('metadata_lookup','id'); $this->addPrimaryKey('metadata_lookup_tree','id'); $this->addPrimaryKey('mime_documents','id'); + $this->addPrimaryKey('mime_extractors','id'); + $this->addPrimaryKey('mime_extractors',array('mime_type_id','mime_document_id')); $this->addPrimaryKey('mime_types','id'); $this->addPrimaryKey('news','id'); $this->addPrimaryKey('notifications','id'); @@ -646,6 +662,7 @@ class IndexRecreator function addPrimaryKey($table, $primarykey) { + if (!in_array($table, $this->tables)) return; if (is_array($primarykey)) { $primarykey = implode(',', $primarykey); diff --git a/bin/scheduler.php b/bin/scheduler.php index 4997d64..f396e20 100644 --- a/bin/scheduler.php +++ b/bin/scheduler.php @@ -117,24 +117,49 @@ if(!empty($aList)){ $sFreq = $item['frequency']; $sParameters = $item['script_params']; - $iTime = time(); - $iStart = explode(' ', microtime()); - - /* Set up parameters for use by the script - $aParams = explode('|', $sParameters); - - foreach($aParams as $param){ - $aParam = explode('=', $param); - if(!empty($aParam)){ - $$aParam[0] = $aParam[1]; - $sParamList .= "{$aParam[0]} {$aParam[1]} "; + // Check if script is windows or *nix compatible + $extArr = explode('.', $sTaskUrl); + $ext = array_pop($extArr); + $script = implode('.', $extArr); + if(OS_WINDOWS){ + switch($ext){ + case 'sh': + $sTaskUrl = $script.'.bat'; + break; + case 'bin': + $sTaskUrl = $script.'.exe'; + break; + } + }else{ + switch($ext){ + case 'bat': + if(file_exists(KT_DIR . $script.'.sh')){ + $sTaskUrl = $script.'.sh'; + break; + } + // File doesn't exist - log error + $default->log->error("Scheduler: Task script can't be found at ".KT_DIR."{$script}.sh"); + continue; + break; + case 'exe': + if(file_exists(KT_DIR . $script)){ + $sTaskUrl = $script; + break; + } + if(file_exists(KT_DIR . $script.'.bin')){ + $sTaskUrl = $script.'.bin'; + break; + } + // File doesn't exist - log error + $default->log->error("Scheduler: Task script can't be found at ".KT_DIR."{$script} or ".KT_DIR."{$script}.bin"); + continue; + break; } } - */ - - // Run the script as php - //include(KT_DIR . $sTaskUrl); - + + $iTime = time(); + $iStart = explode(' ', microtime()); + // Run the script $file = KT_DIR . escapeshellcmd($sTaskUrl); system("{$file} {$sParameters} >> /dev/null", $retval); diff --git a/bin/win32/installScheduler.php b/bin/win32/installScheduler.php index b1393f3..e16edb6 100644 --- a/bin/win32/installScheduler.php +++ b/bin/win32/installScheduler.php @@ -1,19 +1,11 @@ 'ktscheduler', 'display' => 'ktdmsScheduler', - 'params' => $scriptPath, - 'path' => $phpPath + 'path' => $scriptPath )); ?> diff --git a/bin/win32/schedulerServiceStatus.php b/bin/win32/schedulerServiceStatus.php index 930b0c9..5281972 100644 --- a/bin/win32/schedulerServiceStatus.php +++ b/bin/win32/schedulerServiceStatus.php @@ -2,4 +2,4 @@ var_dump(win32_query_service_status('ktscheduler')); -?> \ No newline at end of file +?> diff --git a/bin/win32/taskrunner.bat b/bin/win32/taskrunner.bat new file mode 100644 index 0000000..dbed1f4 --- /dev/null +++ b/bin/win32/taskrunner.bat @@ -0,0 +1,3 @@ +@echo off +"@@BITROCK_INSTALLDIR@@\php\php.exe" "@@BITROCK_INSTALLDIR@@\knowledgeTree\bin\win32\schedulerService.php" + diff --git a/ktwebdav/lib/KTWebDAVServer.inc.php b/ktwebdav/lib/KTWebDAVServer.inc.php index 18dd7f8..2f5ffc9 100644 --- a/ktwebdav/lib/KTWebDAVServer.inc.php +++ b/ktwebdav/lib/KTWebDAVServer.inc.php @@ -167,7 +167,7 @@ class KTWebDAVServer extends HTTP_WebDAV_Server // Load KTWebDAV config if (!$this->initConfig()) { - $this->ktwebdavLog('Could not load configiration.', 'error'); + $this->ktwebdavLog('Could not load configuration.', 'error'); exit(0); } @@ -437,6 +437,22 @@ class KTWebDAVServer extends HTTP_WebDAV_Server $path = $options["path"]; + // Fix for Mac Clients + // Mac adds DS_Store files when folders are added and ._filename files when files are added + // The PUT function doesn't add these files to the dms but PROPFIND still looks for the .DS_Store file, + // and returns an error if not found. We emulate its existence by returning a positive result. + if($this->dav_client == 'MC' || $this->dav_client == 'MG'){ + // Remove filename from path + $aPath = explode('/', $path); + $fileName = $aPath[count($aPath)-1]; + + if(strtolower($fileName) == '.ds_store'){ + $this->ktwebdavLog("Using a Mac client. Filename is .DS_Store so we emulate a positive result.", 'info', true); + // ignore + return true; + } + } + list($iFolderID, $iDocumentID) = $this->_folderOrDocument($path); $this->ktwebdavLog("Folder/Doc is " . print_r(array($iFolderID, $iDocumentID), true), 'info', true); @@ -664,7 +680,7 @@ class KTWebDAVServer extends HTTP_WebDAV_Server } else { $options["depth"] = "infinity"; } - + // analyze request payload $propinfo = new _parse_propfind("php://input"); if (!$propinfo->success) { @@ -798,8 +814,22 @@ class KTWebDAVServer extends HTTP_WebDAV_Server echo " \n"; - $href = htmlspecialchars($this->_slashify($this->_mergePathes($_SERVER['SCRIPT_NAME'], $path))); - + $tempHref = $this->_mergePathes($_SERVER['SCRIPT_NAME'], $path); + + // Ensure collections end in a slash + if(isset($file['props'])){ + foreach($file['props'] as $v){ + if($v['name'] == 'resourcetype'){ + if($v['val'] == 'collection'){ + $tempHref = $this->_slashify($tempHref); + continue; + } + } + } + } + + $href = htmlspecialchars($tempHref); + echo " $href\n"; $this->ktwebdavLog("\nfile is: " . print_r($file, true), 'info', true); @@ -1101,7 +1131,7 @@ class KTWebDAVServer extends HTTP_WebDAV_Server while (count($aRemaining)) { $sFolderName = $aRemaining[0]; $aRemaining = array_slice($aRemaining, 1); - if ($sFolderName == '') { + if (empty($sFolderName)) { continue; } // FIXME: Direct database access @@ -1187,6 +1217,29 @@ class KTWebDAVServer extends HTTP_WebDAV_Server $this->ktwebdavLog("dav_client is: " . $this->dav_client, 'info', true); $path = $options["path"]; + + // Fix for Mac + // Mac adds DS_Store files when folders are added and ._filename files when files are added + // we want to ignore them. + if($this->dav_client == 'MC' || $this->dav_client == 'MG'){ + // Remove filename from path + $aPath = explode('/', $path); + $fileName = $aPath[count($aPath)-1]; + + if(strtolower($fileName) == '.ds_store'){ + $this->ktwebdavLog("Using a mac client. Ignore the .DS_Store files created with every folder.", 'info', true); + // ignore + return "204 No Content"; + } + + if($fileName[0] == '.' && $fileName[1] == '_'){ + $fileName = substr($fileName, 2); + $this->ktwebdavLog("Using a mac client. Ignore the ._filename files created with every file.", 'info', true); + // ignore + return "204 No Content"; + } + } + $res = $this->_folderOrDocument($path); list($iFolderID, $iDocumentID) = $res; @@ -1623,6 +1676,18 @@ class KTWebDAVServer extends HTTP_WebDAV_Server function _MOVEDocument($options, $iFolderID, $iDocumentID) { if ($options['dest'] == '') $options["dest"] = substr($options["dest_url"], strlen($_SERVER["SCRIPT_NAME"])); + + // Fix for Mac + if($this->dav_client == 'MG'){ + $this->ktwebdavLog("Remove ktwebdav from destination path: ".$options['dest'], 'info', true); + if(!(strpos($options['dest'], 'ktwebdav/ktwebdav.php/') === FALSE)){ + $options['dest'] = substr($options['dest'], 22); + } + if($options['dest'][0] != '/'){ + $options['dest'] = '/'.$options['dest']; + } + } + $this->ktwebdavLog("Entering _MOVEDocument. options are " . print_r($options, true), 'info', true); global $default; $new = true; @@ -1643,7 +1708,7 @@ class KTWebDAVServer extends HTTP_WebDAV_Server // return "412 Precondition Failed - This is a Rename. Overwrite needs to be TRUE."; //} $this->ktwebdavLog("Got an oDocument of " . print_r($oDocument, true), 'info', true); - $this->ktwebdavLog("Got an new name of " . basename($dest_path), 'info', true); + $this->ktwebdavLog("Got a new name of " . basename($dest_path), 'info', true); // Check if the user has permissions to write this document $oPerm =& KTPermission::getByName('ktcore.permissions.write'); @@ -2194,10 +2259,15 @@ class KTWebDAVServer extends HTTP_WebDAV_Server $this->ktwebdavLog("WebDAV Client : " . $userAgentValue, 'info', true); } // Mac Finder - if (stristr($userAgentValue,"Macintosh")) { + if (stristr($userAgentValue,"Macintosh") || stristr($userAgentValue,"Darwin")) { $this->dav_client = "MC"; $this->ktwebdavLog("WebDAV Client : " . $userAgentValue, 'info', true); } + // Mac Goliath + if (stristr($userAgentValue,"Goliath")) { + $this->dav_client = "MG"; + $this->ktwebdavLog("WebDAV Client : " . $userAgentValue, 'info', true); + } // Konqueror if (stristr($userAgentValue,"Konqueror")) { $this->dav_client = "KO"; @@ -2228,6 +2298,20 @@ class KTWebDAVServer extends HTTP_WebDAV_Server return false; } + // Mac Goliath + if ($this->dav_client == 'MG' && $this->safeMode == 'off') { + + $this->ktwebdavLog("This is a Mac Goliath type client with SafeMode off.", 'info', true); + return true; + + } + // Mac Goliath + if ($this->dav_client == 'MG' && $this->safeMode != 'off') { + + $this->ktwebdavLog("This is a Mac Goliath type client with SafeMode on.", 'info', true); + return false; + + } // Konqueror if ($this->dav_client == 'KO' && $this->safeMode == 'off') { diff --git a/lib/subscriptions/subscriptions.inc.php b/lib/subscriptions/subscriptions.inc.php index bad824a..69c2788 100644 --- a/lib/subscriptions/subscriptions.inc.php +++ b/lib/subscriptions/subscriptions.inc.php @@ -94,56 +94,54 @@ class SubscriptionEvent { // only useful for folder subscriptions. $aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]); - $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. - foreach ($aUsers as $oSubscriber) { - - // notification object first. - $aNotificationOptions = array(); - $aNotificationOptions['target_user'] = $oSubscriber->getID(); - $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null. - $aNotificationOptions['target_name'] = $oAddedFolder->getName(); - $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId()); - $aNotificationOptions['object_id'] = $oAddedFolder->getId(); // parent folder_id, in this case. - $aNotificationOptions['event_type'] = "AddFolder"; - $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); - - // now the email content. - // FIXME this needs to be handled entirely within notifications from now on. - if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { - $emailContent = $content->getEmailAlertContent($oNotification); - $emailSubject = $content->getEmailAlertSubject($oNotification); - $oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent); - $oEmail->send(); - } - } + foreach ($aUsers as $oSubscriber) { + + // notification object first. + $aNotificationOptions = array(); + $aNotificationOptions['target_user'] = $oSubscriber->getID(); + $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null. + $aNotificationOptions['target_name'] = $oAddedFolder->getName(); + $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId()); + $aNotificationOptions['object_id'] = $oAddedFolder->getId(); // parent folder_id, in this case. + $aNotificationOptions['event_type'] = "AddFolder"; + $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); + + // now the email content. + // FIXME this needs to be handled entirely within notifications from now on. + if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { + $emailContent = $content->getEmailAlertContent($oNotification); + $emailSubject = $content->getEmailAlertSubject($oNotification); + $oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent); + $oEmail->send(); + } + } } function AddDocument ($oAddedDocument, $oParentFolder) { $content = new SubscriptionContent(); // needed for i18n // two parts to this: $aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]); - $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. - foreach ($aUsers as $oSubscriber) { - - // notification object first. - $aNotificationOptions = array(); - $aNotificationOptions['target_user'] = $oSubscriber->getID(); - $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null - is this valid? - $aNotificationOptions['target_name'] = $oAddedDocument->getName(); - $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId()); - $aNotificationOptions['object_id'] = $oAddedDocument->getId(); // parent folder_id, in this case. - $aNotificationOptions['event_type'] = "AddDocument"; - - $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); - - // now the email content. - // FIXME this needs to be handled entirely within notifications from now on. - if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { - $emailContent = $content->getEmailAlertContent($oNotification); - $emailSubject = $content->getEmailAlertSubject($oNotification); - $oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent); - $oEmail->send(); - } - } + foreach ($aUsers as $oSubscriber) { + + // notification object first. + $aNotificationOptions = array(); + $aNotificationOptions['target_user'] = $oSubscriber->getID(); + $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null - is this valid? + $aNotificationOptions['target_name'] = $oAddedDocument->getName(); + $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId()); + $aNotificationOptions['object_id'] = $oAddedDocument->getId(); // parent folder_id, in this case. + $aNotificationOptions['event_type'] = "AddDocument"; + + $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); + + // now the email content. + // FIXME this needs to be handled entirely within notifications from now on. + if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { + $emailContent = $content->getEmailAlertContent($oNotification); + $emailSubject = $content->getEmailAlertSubject($oNotification); + $oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent); + $oEmail->send(); + } + } } function RemoveFolder($oRemovedFolder, $oParentFolder) { $content = new SubscriptionContent(); // needed for i18n @@ -153,7 +151,6 @@ class SubscriptionEvent { // we need to start with the latter, so we don't "lose" any. $aUsers = $this->_getSubscribers($oRemovedFolder->getId(), $this->subscriptionTypes["Folder"]); - $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. foreach ($aUsers as $oSubscriber) { // notification object first. @@ -184,7 +181,6 @@ class SubscriptionEvent { // now handle (for those who haven't been alerted) users watching the folder. $aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]); - $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. foreach ($aUsers as $oSubscriber) { // notification object first. @@ -216,7 +212,6 @@ class SubscriptionEvent { // we need to start with the latter, so we don't "lose" any. $aUsers = $this->_getSubscribers($oRemovedDocument->getId(), $this->subscriptionTypes["Document"]); - $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. foreach ($aUsers as $oSubscriber) { // notification object first. @@ -247,7 +242,6 @@ class SubscriptionEvent { // now handle (for those who haven't been alerted) users watching the folder. $aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]); - $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. foreach ($aUsers as $oSubscriber) { // notification object first. @@ -275,7 +269,6 @@ class SubscriptionEvent { $content = new SubscriptionContent(); // needed for i18n // OK: two actions: document registrants, folder registrants. $aUsers = $this->_getSubscribers($oModifiedDocument->getId(), $this->subscriptionTypes["Document"]); - $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. foreach ($aUsers as $oSubscriber) { // notification object first. @@ -300,7 +293,6 @@ class SubscriptionEvent { $aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]); - $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. foreach ($aUsers as $oSubscriber) { // notification object first. @@ -328,7 +320,6 @@ class SubscriptionEvent { $content = new SubscriptionContent(); // needed for i18n // OK: two actions: document registrants, folder registrants. $aUsers = $this->_getSubscribers($oModifiedDocument->getId(), $this->subscriptionTypes["Document"]); - $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. foreach ($aUsers as $oSubscriber) { // notification object first. @@ -352,7 +343,6 @@ class SubscriptionEvent { } $aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]); - $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. foreach ($aUsers as $oSubscriber) { // notification object first. @@ -380,7 +370,6 @@ class SubscriptionEvent { $content = new SubscriptionContent(); // needed for i18n // OK: two actions: document registrants, folder registrants. $aUsers = $this->_getSubscribers($oModifiedDocument->getId(), $this->subscriptionTypes["Document"]); - $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. foreach ($aUsers as $oSubscriber) { // notification object first. @@ -405,7 +394,7 @@ class SubscriptionEvent { $aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]); - $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. + foreach ($aUsers as $oSubscriber) { // notification object first. @@ -433,60 +422,58 @@ class SubscriptionEvent { $content = new SubscriptionContent(); // needed for i18n // OK: two actions: document registrants, folder registrants. $aUsers = $this->_getSubscribers($oModifiedDocument->getId(), $this->subscriptionTypes["Document"]); - $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. - foreach ($aUsers as $oSubscriber) { - - // notification object first. - $aNotificationOptions = array(); - $aNotificationOptions['target_user'] = $oSubscriber->getID(); - $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null. - $aNotificationOptions['target_name'] = $oModifiedDocument->getName(); - $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId()); - $aNotificationOptions['object_id'] = $oModifiedDocument->getId(); // parent folder_id, in this case. - $aNotificationOptions['event_type'] = "CheckOutDocument"; - $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); - - // now the email content. - // FIXME this needs to be handled entirely within notifications from now on. - if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { - $emailContent = $content->getEmailAlertContent($oNotification); - $emailSubject = $content->getEmailAlertSubject($oNotification); - $oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent); - $oEmail->send(); - } - } + + foreach ($aUsers as $oSubscriber) { + + // notification object first. + $aNotificationOptions = array(); + $aNotificationOptions['target_user'] = $oSubscriber->getID(); + $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null. + $aNotificationOptions['target_name'] = $oModifiedDocument->getName(); + $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId()); + $aNotificationOptions['object_id'] = $oModifiedDocument->getId(); // parent folder_id, in this case. + $aNotificationOptions['event_type'] = "CheckOutDocument"; + $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); + + // now the email content. + // FIXME this needs to be handled entirely within notifications from now on. + if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { + $emailContent = $content->getEmailAlertContent($oNotification); + $emailSubject = $content->getEmailAlertSubject($oNotification); + $oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent); + $oEmail->send(); + } + } $aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]); - $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. - foreach ($aUsers as $oSubscriber) { - - // notification object first. - $aNotificationOptions = array(); - $aNotificationOptions['target_user'] = $oSubscriber->getID(); - $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null. - $aNotificationOptions['target_name'] = $oModifiedDocument->getName(); - $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId()); - $aNotificationOptions['object_id'] = $oModifiedDocument->getId(); // parent folder_id, in this case. - $aNotificationOptions['event_type'] = "CheckOutDocument"; - $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); - - // now the email content. - // FIXME this needs to be handled entirely within notifications from now on. - if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { - $emailContent = $content->getEmailAlertContent($oNotification); - $emailSubject = $content->getEmailAlertSubject($oNotification); - $oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent); - $oEmail->send(); - } - } + foreach ($aUsers as $oSubscriber) { + + // notification object first. + $aNotificationOptions = array(); + $aNotificationOptions['target_user'] = $oSubscriber->getID(); + $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null. + $aNotificationOptions['target_name'] = $oModifiedDocument->getName(); + $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId()); + $aNotificationOptions['object_id'] = $oModifiedDocument->getId(); // parent folder_id, in this case. + $aNotificationOptions['event_type'] = "CheckOutDocument"; + $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); + + // now the email content. + // FIXME this needs to be handled entirely within notifications from now on. + if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { + $emailContent = $content->getEmailAlertContent($oNotification); + $emailSubject = $content->getEmailAlertSubject($oNotification); + $oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent); + $oEmail->send(); + } + } } function MoveDocument($oMovedDocument, $oToFolder, $oFromFolder, $moveOrCopy = "MovedDocument") { $content = new SubscriptionContent(); // needed for i18n // OK: two actions: document registrants, folder registrants. $aUsers = $this->_getSubscribers($oMovedDocument->getId(), $this->subscriptionTypes["Document"]); - $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. foreach ($aUsers as $oSubscriber) { // notification object first. @@ -511,7 +498,7 @@ class SubscriptionEvent { $aUsers = $this->_getSubscribers($oFromFolder->getId(), $this->subscriptionTypes["Folder"]); - $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. + foreach ($aUsers as $oSubscriber) { // notification object first. @@ -535,7 +522,6 @@ class SubscriptionEvent { } $aUsers = $this->_getSubscribers($oToFolder->getId(), $this->subscriptionTypes["Folder"]); - $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. foreach ($aUsers as $oSubscriber) { // notification object first. @@ -563,7 +549,6 @@ class SubscriptionEvent { $content = new SubscriptionContent(); // needed for i18n // OK: two actions: document registrants, folder registrants. $aUsers = $this->_getSubscribers($oModifiedDocument->getId(), $this->subscriptionTypes["Document"]); - $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. foreach ($aUsers as $oSubscriber) { // notification object first. @@ -588,7 +573,6 @@ class SubscriptionEvent { $aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]); - $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. foreach ($aUsers as $oSubscriber) { // notification object first. @@ -616,7 +600,6 @@ class SubscriptionEvent { $content = new SubscriptionContent(); // needed for i18n // OK: two actions: document registrants, folder registrants. $aUsers = $this->_getSubscribers($oModifiedDocument->getId(), $this->subscriptionTypes["Document"]); - $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. foreach ($aUsers as $oSubscriber) { // notification object first. @@ -641,7 +624,6 @@ class SubscriptionEvent { $aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]); - $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. foreach ($aUsers as $oSubscriber) { // notification object first. @@ -669,7 +651,6 @@ class SubscriptionEvent { $content = new SubscriptionContent(); // needed for i18n // OK: two actions: document registrants, folder registrants. $aUsers = $this->_getSubscribers($oDocument->getId(), $this->subscriptionTypes["Document"]); - $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. foreach ($aUsers as $oSubscriber) { // notification object first. @@ -694,7 +675,6 @@ class SubscriptionEvent { $aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]); - $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. foreach ($aUsers as $oSubscriber) { // notification object first. @@ -748,6 +728,9 @@ class SubscriptionEvent { $aNewUsers = DBUtil::getResultArrayKey(array($sQuery, $aParams), "user_id"); + // Remove alerted users + $aNewUsers = $this->_pruneAlertedUsers($aNewUsers); + // notionally less efficient than the old code. if its a big issue, can easily // be refactored. foreach ($aNewUsers as $iUserId) { diff --git a/lib/util/ktutil.inc b/lib/util/ktutil.inc index dcdd44e..99e9fbe 100644 --- a/lib/util/ktutil.inc +++ b/lib/util/ktutil.inc @@ -557,6 +557,12 @@ class KTUtil { return $sCommand . ".exe"; } + $result = KTUtil::checkForStackCommand($sConfigVar); + if (!empty($result)) + { + return $result; + } + $sExecSearchPath = $oKTConfig->get("KnowledgeTree/execSearchPath"); $sExecSearchPath .= PATH_SEPARATOR . KT_DIR . "/../common/"; $sExecSearchPath .= PATH_SEPARATOR . KT_DIR . "/../bin/xpdf/"; @@ -578,6 +584,47 @@ class KTUtil { } // }}} + function checkForStackCommand($configCommand) + { + $config = KTConfig::getSingleton(); + $stackPath = realpath(KT_DIR . '/..'); + + switch ($configCommand) + { + case 'externalBinary/php': + if (OS_WINDOWS) + { + $script = $stackPath . '/php/php.exe'; + } + else + { + $script = $stackPath . '/php/bin/php'; + } + break; + case 'externalBinary/python': + if (OS_WINDOWS) + { + $script = $stackPath . '/openoffice/openoffice/program/python.bat'; + } + else + { + $script = $stackPath . '/openoffice/program/python'; + } + break; + case 'externalBinary/java': + $script = $stackPath . '/j2re/bin/java'; + break; + default: + return null; + } + if (is_file($script)) + { + return $script; + } + return false; + } + + // now accepts strings OR arrays! // {{{ addQueryString static function addQueryString($url, $qs) { diff --git a/plugins/search2/IndexingStatusDashlet.php b/plugins/search2/IndexingStatusDashlet.php index 9962b08..873922d 100644 --- a/plugins/search2/IndexingStatusDashlet.php +++ b/plugins/search2/IndexingStatusDashlet.php @@ -36,13 +36,13 @@ class IndexingStatusDashlet extends KTBaseDashlet function IndexingStatusDashlet() { - $this->sTitle = _kt('Indexing Status'); + $this->sTitle = _kt('Document Indexer Status'); $this->sClass = 'ktError'; } function is_active($oUser) { - if (!Permission::userIsSystemAdministrator($oUser)) + if (!Permission::userIsSystemAdministrator()) { return false; } @@ -86,6 +86,10 @@ class IndexingStatusDashlet extends KTBaseDashlet $_SESSION['IndexingStatus']['extractorDiagnosis'] = $this->extractorDiagnosis; } + if (empty($this->indexerDiagnosis) && empty($this->extractorDiagnosis)) + { + return false; + } return true; } diff --git a/plugins/search2/LuceneStatisticsDashlet.php b/plugins/search2/LuceneStatisticsDashlet.php index 6b6347b..244b22d 100644 --- a/plugins/search2/LuceneStatisticsDashlet.php +++ b/plugins/search2/LuceneStatisticsDashlet.php @@ -34,12 +34,12 @@ class LuceneStatisticsDashlet extends KTBaseDashlet { function LuceneStatisticsDashlet() { - $this->sTitle = _kt('Lucene Statistics'); + $this->sTitle = _kt('Document Indexer Statistics'); } function is_active($oUser) { - return Permission::userIsSystemAdministrator($oUser); + return Permission::userIsSystemAdministrator(); } function render() diff --git a/search2/indexing/bin/recreateIndex.php b/search2/indexing/bin/recreateIndex.php index 6935890..9840942 100644 --- a/search2/indexing/bin/recreateIndex.php +++ b/search2/indexing/bin/recreateIndex.php @@ -14,6 +14,15 @@ require_once(realpath('../../../config/dmsDefaults.php')); print _kt("Recreate Lucene index") . "...\n"; +$config = KTConfig::getSingleton(); +$indexer = $config->get('indexer/coreClass'); + +if ($indexer != 'PHPLuceneIndexer') +{ + print _kt("This script only works with the PHPLuceneIndexer.") . "\n"; + exit; +} + $sure=false; $indexall = false; if ($argc > 0) @@ -42,14 +51,7 @@ if (!$sure) -$config = KTConfig::getSingleton(); -$indexer = $config->get('indexer/coreClass'); -if ($indexer != 'PHPLuceneIndexer') -{ - print _kt("This script only works with the PHPLuceneIndexer.") . "\n"; - exit; -} require_once('indexing/indexerCore.inc.php'); require_once('indexing/indexers/PHPLuceneIndexer.inc.php'); diff --git a/sql/mysql/upgrade/3.5.0/mime_types.sql b/sql/mysql/upgrade/3.5.0/mime_types.sql index 8c04f8e..0291259 100644 --- a/sql/mysql/upgrade/3.5.0/mime_types.sql +++ b/sql/mysql/upgrade/3.5.0/mime_types.sql @@ -9,5 +9,30 @@ CREATE TABLE `zseq_mime_documents` ( `id` int(11) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -alter table mime_types add extractor varchar(100); +CREATE TABLE `mime_extractors` +( + `id` mediumint(9) NOT NULL, + `name` varchar(50) NOT NULL, + `active` tinyint(4) NOT NULL default '0', + PRIMARY KEY (`id`) +) ENGINE=innodb DEFAULT CHARSET=utf8; + +CREATE TABLE `zseq_mime_extractors` ( + `id` int(11) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +CREATE TABLE `mime_document_mapping` +( + `mime_document_id` int(11) NOT NULL, + `mime_type_id` int(11) NOT NULL, + PRIMARY KEY (`mime_document_id`,`mime_type_id`) +) ENGINE=innodb DEFAULT CHARSET=utf8; + +alter table mime_types add extractor_id mediumint; alter table mime_types add mime_document_id int; + +alter table mime_types add foreign key (extractor_id) references mime_extractors (id); +alter table mime_types add foreign key (mime_document_id) references mime_documents (id); + +alter table mime_document_mapping add foreign key (mime_type_id) references mime_types (id); +alter table mime_document_mapping add foreign key (mime_document_id) references mime_documents (id);