Commit b1b786096087a9948b00a0114c427aaa605f3186

Authored by kevin_fourie
1 parent 0670f9fa

Merged in from DEV trunk...

KTS-673
"The search algorithm needs some work"
Updated. Associate mime types with extractors

Committed By: Conrad Vermeulen
Reviewed By: Kevin Fourie


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/STABLE/trunk@7349 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/upgrades/UpgradeFunctions.inc.php
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 * License Version 1.1.2 ("License"); You may not use this file except in 6 * License Version 1.1.2 ("License"); You may not use this file except in
7 * compliance with the License. You may obtain a copy of the License at 7 * compliance with the License. You may obtain a copy of the License at
8 * http://www.knowledgetree.com/KPL 8 * http://www.knowledgetree.com/KPL
9 - * 9 + *
10 * Software distributed under the License is distributed on an "AS IS" 10 * Software distributed under the License is distributed on an "AS IS"
11 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 11 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
12 * See the License for the specific language governing rights and 12 * See the License for the specific language governing rights and
@@ -17,9 +17,9 @@ @@ -17,9 +17,9 @@
17 * (ii) the KnowledgeTree copyright notice 17 * (ii) the KnowledgeTree copyright notice
18 * in the same form as they appear in the distribution. See the License for 18 * in the same form as they appear in the distribution. See the License for
19 * requirements. 19 * requirements.
20 - * 20 + *
21 * The Original Code is: KnowledgeTree Open Source 21 * The Original Code is: KnowledgeTree Open Source
22 - * 22 + *
23 * The Initial Developer of the Original Code is The Jam Warehouse Software 23 * The Initial Developer of the Original Code is The Jam Warehouse Software
24 * (Pty) Ltd, trading as KnowledgeTree. 24 * (Pty) Ltd, trading as KnowledgeTree.
25 * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright 25 * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright
@@ -31,22 +31,22 @@ @@ -31,22 +31,22 @@
31 31
32 class UpgradeFunctions { 32 class UpgradeFunctions {
33 var $upgrades = array( 33 var $upgrades = array(
34 - "2.0.0" => array("setPermissionFolder"),  
35 - "2.0.6" => array("addTemplateMimeTypes"),  
36 - "2.0.8" => array("setPermissionObject"),  
37 - "2.99.1" => array("createFieldSets"),  
38 - "2.99.7" => array("normaliseDocuments", "applyDiscussionUpgrade"),  
39 - "2.99.8" => array("fixUnits"),  
40 - "2.99.9" => array("createLdapAuthenticationProvider", "createSecurityDeletePermissions"),  
41 - "3.0.1.3" => array('addTransactionTypes3013'),  
42 - "3.0.1.4" => array('createWorkflowPermission'),  
43 - "3.0.2" => array("fixDocumentRoleAllocation"),  
44 - "3.0.3.2" => array("createFolderDetailsPermission"),  
45 - "3.0.3.3" => array("generateWorkflowTriggers"),  
46 - "3.0.3.7" => array("rebuildAllPermissions"),  
47 - "3.1.5" => array("upgradeSavedSearches"),  
48 - "3.1.6.3" => array("cleanupGroupMembership"),  
49 - "3.5.0" => array("cleanupOldKTAdminVersionNotifier"), 34 + '2.0.0' => array('setPermissionFolder'),
  35 + '2.0.6' => array('addTemplateMimeTypes'),
  36 + '2.0.8' => array('setPermissionObject'),
  37 + '2.99.1' => array('createFieldSets'),
  38 + '2.99.7' => array('normaliseDocuments', 'applyDiscussionUpgrade'),
  39 + '2.99.8' => array('fixUnits'),
  40 + '2.99.9' => array('createLdapAuthenticationProvider', 'createSecurityDeletePermissions'),
  41 + '3.0.1.3' => array('addTransactionTypes3013'),
  42 + '3.0.1.4' => array('createWorkflowPermission'),
  43 + '3.0.2' => array('fixDocumentRoleAllocation'),
  44 + '3.0.3.2' => array('createFolderDetailsPermission'),
  45 + '3.0.3.3' => array('generateWorkflowTriggers'),
  46 + '3.0.3.7' => array('rebuildAllPermissions'),
  47 + '3.1.5' => array('upgradeSavedSearches'),
  48 + '3.1.6.3' => array('cleanupGroupMembership'),
  49 + '3.5.0' => array('cleanupOldKTAdminVersionNotifier', 'registerExtractorMapping'),
50 ); 50 );
51 51
52 var $descriptions = array( 52 var $descriptions = array(
@@ -67,6 +67,7 @@ class UpgradeFunctions { @@ -67,6 +67,7 @@ class UpgradeFunctions {
67 'upgradeSavedSearches' => 'Upgrade saved searches to use namespaces instead of integer ids', 67 'upgradeSavedSearches' => 'Upgrade saved searches to use namespaces instead of integer ids',
68 'cleanupGroupMembership' => 'Cleanup any old references to missing groups, etc.', 68 'cleanupGroupMembership' => 'Cleanup any old references to missing groups, etc.',
69 'cleanupOldKTAdminVersionNotifier' => 'Cleanup any old files from the old KTAdminVersionNotifier', 69 'cleanupOldKTAdminVersionNotifier' => 'Cleanup any old files from the old KTAdminVersionNotifier',
  70 + 'registerExtractorMapping' => 'Register document text extractors with the appropriate mime types'
70 ); 71 );
71 var $phases = array( 72 var $phases = array(
72 "setPermissionFolder" => 1, 73 "setPermissionFolder" => 1,
@@ -702,14 +703,14 @@ class UpgradeFunctions { @@ -702,14 +703,14 @@ class UpgradeFunctions {
702 DBUtil::runQuery("UPDATE $sFolderTable SET permission_lookup_id = NULL"); 703 DBUtil::runQuery("UPDATE $sFolderTable SET permission_lookup_id = NULL");
703 DBUtil::commit(); 704 DBUtil::commit();
704 } 705 }
705 - // }}} 706 + // }}}
706 707
707 - // {{{ generateWorkflowTriggers 708 + // {{{ generateWorkflowTriggers
708 function generateWorkflowTriggers() { 709 function generateWorkflowTriggers() {
709 710
710 - require_once(KT_LIB_DIR . '/workflow/workflowutil.inc.php'); 711 + require_once(KT_LIB_DIR . '/workflow/workflowutil.inc.php');
711 712
712 - // get all the transitions, and add a trigger to the util with the appropriate settings. 713 + // get all the transitions, and add a trigger to the util with the appropriate settings.
713 $KTWFTriggerReg =& KTWorkflowTriggerRegistry::getSingleton(); 714 $KTWFTriggerReg =& KTWorkflowTriggerRegistry::getSingleton();
714 $aTransitions = KTWorkflowTransition::getList(); 715 $aTransitions = KTWorkflowTransition::getList();
715 foreach ($aTransitions as $oTransition) { 716 foreach ($aTransitions as $oTransition) {
@@ -718,55 +719,55 @@ class UpgradeFunctions { @@ -718,55 +719,55 @@ class UpgradeFunctions {
718 $iGuardPerm = $oTransition->getGuardPermissionId(); 719 $iGuardPerm = $oTransition->getGuardPermissionId();
719 if (!is_null($iGuardPerm)) { 720 if (!is_null($iGuardPerm)) {
720 721
721 - $sNamespace = 'ktcore.workflowtriggers.permissionguard'; 722 + $sNamespace = 'ktcore.workflowtriggers.permissionguard';
722 $oPerm = KTPermission::get($iGuardPerm); 723 $oPerm = KTPermission::get($iGuardPerm);
723 - $oTrigger = $KTWFTriggerReg->getWorkflowTrigger($sNamespace); 724 + $oTrigger = $KTWFTriggerReg->getWorkflowTrigger($sNamespace);
724 $oTriggerConfig = KTWorkflowTriggerInstance::createFromArray(array( 725 $oTriggerConfig = KTWorkflowTriggerInstance::createFromArray(array(
725 'transitionid' => KTUtil::getId($oTransition), 726 'transitionid' => KTUtil::getId($oTransition),
726 'namespace' => $sNamespace, 727 'namespace' => $sNamespace,
727 'config' => array('perms' => array($oPerm->getName())), 728 'config' => array('perms' => array($oPerm->getName())),
728 - )); 729 + ));
729 730
730 } 731 }
731 // guard group 732 // guard group
732 $iGuardGroup = $oTransition->getGuardGroupId(); 733 $iGuardGroup = $oTransition->getGuardGroupId();
733 if (!is_null($iGuardGroup)) { 734 if (!is_null($iGuardGroup)) {
734 735
735 - $sNamespace = 'ktcore.workflowtriggers.groupguard';  
736 - $oTrigger = $KTWFTriggerReg->getWorkflowTrigger($sNamespace); 736 + $sNamespace = 'ktcore.workflowtriggers.groupguard';
  737 + $oTrigger = $KTWFTriggerReg->getWorkflowTrigger($sNamespace);
737 $oTriggerConfig = KTWorkflowTriggerInstance::createFromArray(array( 738 $oTriggerConfig = KTWorkflowTriggerInstance::createFromArray(array(
738 'transitionid' => KTUtil::getId($oTransition), 739 'transitionid' => KTUtil::getId($oTransition),
739 'namespace' => $sNamespace, 740 'namespace' => $sNamespace,
740 'config' => array('group_id' => $iGuardGroup), 741 'config' => array('group_id' => $iGuardGroup),
741 - )); 742 + ));
742 743
743 - }  
744 - // guard role 744 + }
  745 + // guard role
745 $iGuardRole = $oTransition->getGuardRoleId(); 746 $iGuardRole = $oTransition->getGuardRoleId();
746 if (!is_null($iGuardRole)) { 747 if (!is_null($iGuardRole)) {
747 748
748 - $sNamespace = 'ktcore.workflowtriggers.roleguard';  
749 - $oTrigger = $KTWFTriggerReg->getWorkflowTrigger($sNamespace); 749 + $sNamespace = 'ktcore.workflowtriggers.roleguard';
  750 + $oTrigger = $KTWFTriggerReg->getWorkflowTrigger($sNamespace);
750 $oTriggerConfig = KTWorkflowTriggerInstance::createFromArray(array( 751 $oTriggerConfig = KTWorkflowTriggerInstance::createFromArray(array(
751 'transitionid' => KTUtil::getId($oTransition), 752 'transitionid' => KTUtil::getId($oTransition),
752 'namespace' => $sNamespace, 753 'namespace' => $sNamespace,
753 'config' => array('role_id' => $iGuardRole), 754 'config' => array('role_id' => $iGuardRole),
754 - )); 755 + ));
755 756
756 } 757 }
757 // guard condition 758 // guard condition
758 $iGuardCondition = $oTransition->getGuardConditionId(); 759 $iGuardCondition = $oTransition->getGuardConditionId();
759 if (!is_null($iGuardCondition)) { 760 if (!is_null($iGuardCondition)) {
760 761
761 - $sNamespace = 'ktcore.workflowtriggers.conditionguard';  
762 - $oTrigger = $KTWFTriggerReg->getWorkflowTrigger($sNamespace); 762 + $sNamespace = 'ktcore.workflowtriggers.conditionguard';
  763 + $oTrigger = $KTWFTriggerReg->getWorkflowTrigger($sNamespace);
763 $oTriggerConfig = KTWorkflowTriggerInstance::createFromArray(array( 764 $oTriggerConfig = KTWorkflowTriggerInstance::createFromArray(array(
764 'transitionid' => KTUtil::getId($oTransition), 765 'transitionid' => KTUtil::getId($oTransition),
765 'namespace' => $sNamespace, 766 'namespace' => $sNamespace,
766 'config' => array('condition_id' => $iGuardCondition), 767 'config' => array('condition_id' => $iGuardCondition),
767 - )); 768 + ));
768 769
769 - } 770 + }
770 } 771 }
771 772
772 } 773 }
@@ -856,13 +857,13 @@ class UpgradeFunctions { @@ -856,13 +857,13 @@ class UpgradeFunctions {
856 return $res; 857 return $res;
857 } else { 858 } else {
858 $bad_group_links = kt_array_merge($bad_group_links, $res); 859 $bad_group_links = kt_array_merge($bad_group_links, $res);
859 - } 860 + }
860 861
861 foreach ($bad_group_links as $link_id) { 862 foreach ($bad_group_links as $link_id) {
862 $res = DBUtil::runQuery(array("DELETE FROM groups_groups_link WHERE id = ?", $link_id)); 863 $res = DBUtil::runQuery(array("DELETE FROM groups_groups_link WHERE id = ?", $link_id));
863 if (PEAR::isError($res)) { 864 if (PEAR::isError($res)) {
864 return $res; 865 return $res;
865 - } 866 + }
866 } 867 }
867 868
868 $res = DBUtil::getResultArrayKey(array($group_query, null), 'link_id'); 869 $res = DBUtil::getResultArrayKey(array($group_query, null), 'link_id');
@@ -875,7 +876,7 @@ class UpgradeFunctions { @@ -875,7 +876,7 @@ class UpgradeFunctions {
875 $res = DBUtil::getResultArrayKey(array($user_query, null), 'link_id'); 876 $res = DBUtil::getResultArrayKey(array($user_query, null), 'link_id');
876 if (PEAR::isError($res)) { 877 if (PEAR::isError($res)) {
877 return $res; 878 return $res;
878 - } else { 879 + } else {
879 $bad_user_links = kt_array_merge($bad_user_links, $res); 880 $bad_user_links = kt_array_merge($bad_user_links, $res);
880 } 881 }
881 882
@@ -883,12 +884,12 @@ class UpgradeFunctions { @@ -883,12 +884,12 @@ class UpgradeFunctions {
883 $res = DBUtil::runQuery(array("DELETE FROM users_groups_link WHERE id = ?", $link_id)); 884 $res = DBUtil::runQuery(array("DELETE FROM users_groups_link WHERE id = ?", $link_id));
884 if (PEAR::isError($res)) { 885 if (PEAR::isError($res)) {
885 return $res; 886 return $res;
886 - } 887 + }
887 } 888 }
888 889
889 return true; 890 return true;
890 891
891 - } 892 + }
892 // }}} 893 // }}}
893 894
894 // {{{ cleanupOldKTAdminVersionNotifier 895 // {{{ cleanupOldKTAdminVersionNotifier
@@ -899,8 +900,15 @@ class UpgradeFunctions { @@ -899,8 +900,15 @@ class UpgradeFunctions {
899 if(file_exists($oldFile)) return unlink($oldFile); 900 if(file_exists($oldFile)) return unlink($oldFile);
900 901
901 return true; 902 return true;
902 - } 903 + }
903 // }}} 904 // }}}
  905 +
  906 + function registerExtractorMapping()
  907 + {
  908 + $indexer = Indexer::get();
  909 + $indexer->registerTypes();
  910 + }
  911 +
904 } 912 }
905 913
906 ?> 914 ?>