Commit 4a71e74b20082d9a90c3cb4beff8946f86541587
Merge branch 'master' of git@github.com:ktgit/knowledgetree
Showing
11 changed files
with
396 additions
and
59 deletions
lib/database/schema.inc.php
plugins/ktcore/KTPermissions.php
| ... | ... | @@ -874,7 +874,7 @@ class KTDocumentRolesAction extends KTDocumentAction { |
| 874 | 874 | function do_main() { |
| 875 | 875 | $this->oPage->setTitle(_kt("View Roles")); |
| 876 | 876 | $this->oPage->setBreadcrumbDetails(_kt("View Roles")); |
| 877 | - $oTemplating = new KTTemplating; | |
| 877 | + $oTemplating =& KTTemplating::getSingleton(); | |
| 878 | 878 | $oTemplate = $oTemplating->loadTemplate("ktcore/action/view_roles"); |
| 879 | 879 | |
| 880 | 880 | // we need to have: | ... | ... |
search2/documentProcessor/documentProcessor.inc.php
search2/indexing/extractorCore.inc.php
| ... | ... | @@ -695,7 +695,6 @@ abstract class TextExtractor extends DocumentExtractor |
| 695 | 695 | */ |
| 696 | 696 | public function extractTextContent() |
| 697 | 697 | { |
| 698 | - | |
| 699 | 698 | $config = KTConfig::getSingleton(); |
| 700 | 699 | $maxTextSize = $config->get('indexer/maxTextSize', 1024 * 1024 * 10); // we'll only take 10 meg by default |
| 701 | 700 | $content = file_get_contents($this->sourcefile, null, null, null, $maxTextSize); | ... | ... |
search2/indexing/indexerCore.inc.php
| ... | ... | @@ -1255,6 +1255,15 @@ abstract class Indexer |
| 1255 | 1255 | // increment indexed documents count |
| 1256 | 1256 | Indexer::incrementCount(); |
| 1257 | 1257 | |
| 1258 | + // if document is a zero byte file, let's just unqueue and return | |
| 1259 | + if ($document->getFileSize() == 0) | |
| 1260 | + { | |
| 1261 | + Indexer::unqueueDocument($docinfo['document_id'], | |
| 1262 | + sprintf(_kt("Zero Byte documents do not need to be indexed: %d"), | |
| 1263 | + $docinfo['document_id'])); | |
| 1264 | + return; | |
| 1265 | + } | |
| 1266 | + | |
| 1258 | 1267 | $docId = $docinfo['document_id']; |
| 1259 | 1268 | $extension = $docinfo['filetypes']; |
| 1260 | 1269 | $mimeType = $docinfo['mimetypes']; |
| ... | ... | @@ -1312,7 +1321,7 @@ abstract class Indexer |
| 1312 | 1321 | Indexer::unqueueDocument($docId,sprintf(_kt("indexDocuments: Filename for document id %d starts with a tilde (~). This is assumed to be a temporary file. This is ignored."),$docId), 'error'); |
| 1313 | 1322 | return ; |
| 1314 | 1323 | } |
| 1315 | - | |
| 1324 | + | |
| 1316 | 1325 | $removeFromQueue = true; |
| 1317 | 1326 | if ($indexDocument) |
| 1318 | 1327 | { | ... | ... |
setup/upgrade.php
| ... | ... | @@ -183,10 +183,11 @@ if (PEAR::isError($dbSupport)) { |
| 183 | 183 | |
| 184 | 184 | |
| 185 | 185 | ?> |
| 186 | +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"> | |
| 186 | 187 | <html> |
| 187 | 188 | <head> |
| 188 | 189 | <title><?php echo APP_NAME;?> Upgrade</title> |
| 189 | - <style> | |
| 190 | + <style type="text/css"> | |
| 190 | 191 | th { text-align: left; } |
| 191 | 192 | td { vertical-align: top; } |
| 192 | 193 | .foo { float: left; } |
| ... | ... | @@ -203,13 +204,13 @@ td { vertical-align: top; } |
| 203 | 204 | echo $oKTConfig->get('ui/mainLogo'); |
| 204 | 205 | }else{ |
| 205 | 206 | echo '../resources/graphics/ktlogo-topbar_base.png'; |
| 206 | - }?>"> | |
| 207 | + }?>"/> | |
| 207 | 208 | <p> |
| 208 | - <img src="upgrade-title.jpg"> | |
| 209 | - <table width=800 height=500> | |
| 209 | + <img src="upgrade-title.jpg"/> | |
| 210 | + <table style="width:800; height:500"> | |
| 210 | 211 | <tr><td> |
| 211 | 212 | <P> |
| 212 | - <script> | |
| 213 | + <script type="text/javascript"> | |
| 213 | 214 | function do_start(action) |
| 214 | 215 | { |
| 215 | 216 | document.location='?go=' + action; |
| ... | ... | @@ -458,8 +459,8 @@ function create_restore_stmt($targetfile) |
| 458 | 459 | |
| 459 | 460 | $tmpdir=resolveTempDir(); |
| 460 | 461 | |
| 461 | - $stmt = $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism drop \"$dbName\"<br>"; | |
| 462 | - $stmt .= $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism create \"$dbName\"<br>"; | |
| 462 | + $stmt = $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism drop \"$dbName\"<br/>"; | |
| 463 | + $stmt .= $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism create \"$dbName\"<br/>"; | |
| 463 | 464 | |
| 464 | 465 | |
| 465 | 466 | $stmt .= $prefix ."mysql --user=\"$adminUser\" -p $mechanism \"$dbName\" < \"$targetfile\"\n"; |
| ... | ... | @@ -478,7 +479,7 @@ function title($title) |
| 478 | 479 | { |
| 479 | 480 | if (!isset($_SESSION['setup_user'])) |
| 480 | 481 | { |
| 481 | - print "<script>document.location='?go=Login'</script>"; | |
| 482 | + print "<script type='text/javascript'>document.location='?go=Login'</script>"; | |
| 482 | 483 | } |
| 483 | 484 | print "<h1>$title</h1>"; |
| 484 | 485 | } |
| ... | ... | @@ -511,10 +512,10 @@ function upgradeConfirm() |
| 511 | 512 | if (!isset($_SESSION['backupStatus']) || $_SESSION['backupStatus'] === false) |
| 512 | 513 | { |
| 513 | 514 | ?> |
| 514 | -<br> | |
| 515 | +<br/> | |
| 515 | 516 | <font color="Red">Please ensure that you have made a backup before continuing with the upgrade process.</font> |
| 516 | 517 | <p> |
| 517 | -<br> | |
| 518 | +<br/> | |
| 518 | 519 | <?php |
| 519 | 520 | } |
| 520 | 521 | ?> |
| ... | ... | @@ -550,7 +551,7 @@ Your mysql installation has been resolved. Manually, you would do the following: |
| 550 | 551 | <tr> |
| 551 | 552 | <td> |
| 552 | 553 | <nobr>cd "<?php echo $dir;?>"</nobr> |
| 553 | -<br> | |
| 554 | +<br/> | |
| 554 | 555 | <?php |
| 555 | 556 | } |
| 556 | 557 | else |
| ... | ... | @@ -617,7 +618,7 @@ function restoreSelect() |
| 617 | 618 | <P> |
| 618 | 619 | Select a backup to restore from the list below: |
| 619 | 620 | <P> |
| 620 | - <script> | |
| 621 | + <script type="text/javascript"> | |
| 621 | 622 | function selectRestore(filename) |
| 622 | 623 | { |
| 623 | 624 | document.location='?go=RestoreSelected&file=' + filename; |
| ... | ... | @@ -659,7 +660,7 @@ function restoreSelected() |
| 659 | 660 | $dir = resolveTempDir(); |
| 660 | 661 | $_SESSION['backupFile'] = $dir . '/' . $file; |
| 661 | 662 | ?> |
| 662 | -<script> | |
| 663 | +<script type="text/javascript"> | |
| 663 | 664 | document.location='?go=RestoreConfirm'; |
| 664 | 665 | </script> |
| 665 | 666 | <?php |
| ... | ... | @@ -691,7 +692,7 @@ Manually, you would do the following to restore the backup: |
| 691 | 692 | <tr> |
| 692 | 693 | <td> |
| 693 | 694 | <nobr>cd "<?php echo $dir;?>"</nobr> |
| 694 | -<br> | |
| 695 | +<br/> | |
| 695 | 696 | <?php |
| 696 | 697 | } |
| 697 | 698 | else |
| ... | ... | @@ -709,6 +710,8 @@ You can continue to do the restore manually using the following command(s): |
| 709 | 710 | } |
| 710 | 711 | ?> |
| 711 | 712 | <nobr><?php echo $stmt['display'];?></nobr> |
| 713 | +</td> | |
| 714 | +</tr> | |
| 712 | 715 | </table> |
| 713 | 716 | <P> |
| 714 | 717 | <?php |
| ... | ... | @@ -729,7 +732,7 @@ Press <i>continue to restore</i> to attempt the command(s) above. |
| 729 | 732 | if ($dir != '') |
| 730 | 733 | { |
| 731 | 734 | ?> |
| 732 | -<script> | |
| 735 | +<script type="text/javascript"> | |
| 733 | 736 | function restore() |
| 734 | 737 | { |
| 735 | 738 | if (confirm('Are you sure you want to restore? This is your last chance if the current data has not been backed up.')) |
| ... | ... | @@ -758,7 +761,7 @@ function backupDone() |
| 758 | 761 | { |
| 759 | 762 | $stmt=create_restore_stmt($filename); |
| 760 | 763 | ?> |
| 761 | - The backup file <nobr><I>"<?php echo $filename;?>"</i></nobr> has been created. | |
| 764 | + The backup file <nobr><i>"<?php echo $filename;?>"</i></nobr> has been created. | |
| 762 | 765 | <P> It appears as though the <font color=green>backup has been successful</font>. |
| 763 | 766 | <P> |
| 764 | 767 | <?php |
| ... | ... | @@ -771,7 +774,7 @@ function backupDone() |
| 771 | 774 | <tr> |
| 772 | 775 | <td> |
| 773 | 776 | <nobr>cd <?php echo $stmt['dir'];?></nobr> |
| 774 | - <br> | |
| 777 | + <br/> | |
| 775 | 778 | <?php |
| 776 | 779 | } |
| 777 | 780 | else |
| ... | ... | @@ -809,7 +812,7 @@ We appologise for the inconvenience. |
| 809 | 812 | |
| 810 | 813 | } |
| 811 | 814 | ?> |
| 812 | -<br> | |
| 815 | +<br/> | |
| 813 | 816 | |
| 814 | 817 | <input type=button value="back" onclick="javascript:do_start('welcome')"> |
| 815 | 818 | <?php |
| ... | ... | @@ -833,7 +836,7 @@ function restoreDone() |
| 833 | 836 | { |
| 834 | 837 | |
| 835 | 838 | ?> |
| 836 | - The restore of <nobr><I>"<?php echo $filename;?>"</i></nobr> has been completed. | |
| 839 | + The restore of <nobr><i>"<?php echo $filename;?>"</i></nobr> has been completed. | |
| 837 | 840 | <P> |
| 838 | 841 | It appears as though the <font color=green>restore has been successful</font>. |
| 839 | 842 | <P> |
| ... | ... | @@ -861,7 +864,7 @@ We appologise for the inconvenience. |
| 861 | 864 | } |
| 862 | 865 | ?> |
| 863 | 866 | |
| 864 | -<br> | |
| 867 | +<br/> | |
| 865 | 868 | |
| 866 | 869 | <input type=button value="back" onclick="javascript:do_start('welcome')"> |
| 867 | 870 | |
| ... | ... | @@ -878,7 +881,7 @@ function check_state($value, $state='Home') |
| 878 | 881 | if ($_SESSION['state'] != $value) |
| 879 | 882 | { |
| 880 | 883 | ?> |
| 881 | - <script> | |
| 884 | + <script type="text/javascript"> | |
| 882 | 885 | document.location="?go=<?php echo $state;?>"; |
| 883 | 886 | </script> |
| 884 | 887 | <?php |
| ... | ... | @@ -935,7 +938,7 @@ function backup() |
| 935 | 938 | $_SESSION['backupStatus'] = false; |
| 936 | 939 | } |
| 937 | 940 | ?> |
| 938 | - <script> | |
| 941 | + <script type="text/javascript"> | |
| 939 | 942 | document.location="?go=BackupDone"; |
| 940 | 943 | </script> |
| 941 | 944 | <?php |
| ... | ... | @@ -1007,7 +1010,7 @@ function restore() |
| 1007 | 1010 | |
| 1008 | 1011 | |
| 1009 | 1012 | ?> |
| 1010 | - <script> | |
| 1013 | + <script type="text/javascript"> | |
| 1011 | 1014 | document.location="?go=RestoreDone"; |
| 1012 | 1015 | </script> |
| 1013 | 1016 | <?php |
| ... | ... | @@ -1033,22 +1036,22 @@ function welcome() |
| 1033 | 1036 | { |
| 1034 | 1037 | set_state(1); |
| 1035 | 1038 | ?> |
| 1036 | -<br> | |
| 1039 | +<br/> | |
| 1037 | 1040 | Welcome to the <?php echo APP_NAME;?> Database Upgrade Wizard.<P> If you have just updated |
| 1038 | 1041 | your <?php echo APP_NAME;?> code base, you will need to complete the upgrade process in order to ensure your system is fully operational with the new version. |
| 1039 | 1042 | <P> |
| 1040 | 1043 | You will not be able to log into <?php echo APP_NAME;?> until your the database upgrade process is completed. |
| 1041 | 1044 | <P> |
| 1042 | -<font color=orange>!!NB!! You are advised to backup the database before attempting the upgrade. !!NB!!</font> | |
| 1045 | +<font color="#ffa500">!!NB!! You are advised to backup the database before attempting the upgrade. !!NB!!</font> | |
| 1043 | 1046 | <P> |
| 1044 | 1047 | If you have already done this, you may skip this step can continue directly to the upgrade. |
| 1045 | 1048 | <P> |
| 1046 | 1049 | |
| 1047 | 1050 | |
| 1048 | - <input type=button value="cancel" onclick="document.location='..';"> | |
| 1049 | - <input type=button value="backup now" onclick="javascript:do_start('BackupConfirm');"> | |
| 1050 | - <input type=button value="next" onclick="javascript:do_start('UpgradeConfirm');"> | |
| 1051 | - <input type=button value="restore database" onclick="javascript:do_start('RestoreConfirm');"> | |
| 1051 | + <input type=button value="cancel" onclick="document.location='..';"/> | |
| 1052 | + <input type=button value="backup now" onclick="javascript:do_start('BackupConfirm');"/> | |
| 1053 | + <input type=button value="next" onclick="javascript:do_start('UpgradeConfirm');"/> | |
| 1054 | + <input type=button value="restore database" onclick="javascript:do_start('RestoreConfirm');"/> | |
| 1052 | 1055 | |
| 1053 | 1056 | |
| 1054 | 1057 | <?php |
| ... | ... | @@ -1069,7 +1072,7 @@ function UpgradePreview() |
| 1069 | 1072 | $upgradeTable = generateUpgradeTable(); |
| 1070 | 1073 | print $upgradeTable; |
| 1071 | 1074 | ?> |
| 1072 | - <br> | |
| 1075 | + <br/> | |
| 1073 | 1076 | |
| 1074 | 1077 | <input type=button value="back" onclick="javascript:do_start('home')"> |
| 1075 | 1078 | <input type=button value="next" onclick="javascript:do_start('Upgrade')"> |
| ... | ... | @@ -1091,14 +1094,14 @@ function Upgrade() |
| 1091 | 1094 | if (PEAR::isError($pre_res)) |
| 1092 | 1095 | { |
| 1093 | 1096 | ?> |
| 1094 | -<font color="red">Pre-Upgrade actions failed.</font><br> | |
| 1097 | +<font color="red">Pre-Upgrade actions failed.</font><br/> | |
| 1095 | 1098 | <?php |
| 1096 | 1099 | } |
| 1097 | 1100 | else |
| 1098 | 1101 | { |
| 1099 | 1102 | ?> |
| 1100 | 1103 | <p> |
| 1101 | -<font color="green">Pre-Upgrade actions succeeded.</font><br> | |
| 1104 | +<font color="green">Pre-Upgrade actions succeeded.</font><br/> | |
| 1102 | 1105 | <?php |
| 1103 | 1106 | } |
| 1104 | 1107 | ?> |
| ... | ... | @@ -1125,15 +1128,15 @@ function Upgrade() |
| 1125 | 1128 | if (PEAR::isError($post_res)) |
| 1126 | 1129 | { |
| 1127 | 1130 | ?> |
| 1128 | -<font color="red">Post-Upgrade actions failed.</font><br><br> | |
| 1131 | +<font color="red">Post-Upgrade actions failed.</font><br/><br/> | |
| 1129 | 1132 | <?php |
| 1130 | 1133 | } |
| 1131 | 1134 | else |
| 1132 | 1135 | { |
| 1133 | 1136 | ?> |
| 1134 | 1137 | <p> |
| 1135 | -<font color="green">Post-Upgrade actions succeeded.</font><br><br> | |
| 1136 | -<script> | |
| 1138 | +<font color="green">Post-Upgrade actions succeeded.</font><br/><br/> | |
| 1139 | +<script type="text/javascript"> | |
| 1137 | 1140 | alert("To complete the upgrade please do the following before continuing:\n\n1. Restart the services as appropriate for your environment.\n\n\nOn first run of your upgraded installaton please do the following:\n\n1. Hard refresh your bowser (CTRL-F5) on first view of the Dashboard.\n2. Enable the new plugins you wish to use.\n\n\nSelect 'next' at the bottom of this page to continue.") |
| 1138 | 1141 | </script> |
| 1139 | 1142 | <?php |
| ... | ... | @@ -1151,6 +1154,6 @@ function Upgrade() |
| 1151 | 1154 | if($oKTConfig->get('ui/poweredByDisabled') == '0'){ |
| 1152 | 1155 | ?> align="right"><img src="<?php echo $oKTConfig->get('ui/powerLogo');?>"></td> |
| 1153 | 1156 | <?php }else{ ?> |
| 1154 | - background="../resources/graphics/ktbg.png"> </td> | |
| 1157 | + style="background:url('../resources/graphics/ktbg.png')> </td> | |
| 1155 | 1158 | <?php }?> |
| 1156 | 1159 | </table> | ... | ... |
sql/mysql/upgrade/3.1.6.3/groups-integrity.sql
| ... | ... | @@ -2,13 +2,37 @@ |
| 2 | 2 | |
| 3 | 3 | -- parent_group_id |
| 4 | 4 | |
| 5 | -DELETE FROM `groups_groups_link` as gg USING `groups_groups_link` as gg, groups_lookup | |
| 6 | - WHERE not exists(select 1 from `groups_lookup` as g where gg.parent_group_id = g.id); | |
| 5 | +CREATE TEMPORARY TABLE cleanup ( | |
| 6 | + `id` int(11) NOT NULL auto_increment, | |
| 7 | + `parent_group_id` int(11) NOT NULL default '0', | |
| 8 | + `member_group_id` int(11) NOT NULL default '0', | |
| 9 | + PRIMARY KEY (`id`), | |
| 10 | + KEY `parent_group_id` (`parent_group_id`), | |
| 11 | + KEY `member_group_id` (`member_group_id`) | |
| 12 | +); | |
| 13 | +INSERT INTO cleanup (id, parent_group_id, member_group_id) | |
| 14 | +SELECT * FROM `groups_groups_link` AS gg WHERE ( SELECT 1 FROM `groups_lookup` AS g WHERE gg.parent_group_id = g.id); | |
| 15 | +SELECT * FROM cleanup; | |
| 16 | +TRUNCATE groups_groups_link; | |
| 17 | +INSERT groups_groups_link SELECT * FROM cleanup; | |
| 18 | +DROP TABLE cleanup; | |
| 7 | 19 | |
| 8 | 20 | -- member_group_id |
| 9 | 21 | |
| 10 | -DELETE FROM `groups_groups_link` as gg USING `groups_groups_link` as gg, groups_lookup | |
| 11 | - WHERE not exists(select 1 from `groups_lookup` as g where gg.member_group_id = g.id); | |
| 22 | +CREATE TEMPORARY TABLE cleanup ( | |
| 23 | + `id` int(11) NOT NULL auto_increment, | |
| 24 | + `parent_group_id` int(11) NOT NULL default '0', | |
| 25 | + `member_group_id` int(11) NOT NULL default '0', | |
| 26 | + PRIMARY KEY (`id`), | |
| 27 | + KEY `parent_group_id` (`parent_group_id`), | |
| 28 | + KEY `member_group_id` (`member_group_id`) | |
| 29 | +); | |
| 30 | +INSERT INTO cleanup (id, parent_group_id, member_group_id) | |
| 31 | +SELECT * FROM `groups_groups_link` AS gg WHERE ( SELECT 1 FROM `groups_lookup` AS g WHERE gg.member_group_id = g.id); | |
| 32 | +SELECT * FROM cleanup; | |
| 33 | +TRUNCATE groups_groups_link; | |
| 34 | +INSERT groups_groups_link SELECT * FROM cleanup; | |
| 35 | +DROP TABLE cleanup; | |
| 12 | 36 | |
| 13 | 37 | -- ADD CONSTRAINT |
| 14 | 38 | |
| ... | ... | @@ -16,21 +40,44 @@ ALTER TABLE `groups_groups_link` |
| 16 | 40 | ADD CONSTRAINT `groups_groups_link_ibfk_1` FOREIGN KEY (`parent_group_id`) REFERENCES `groups_lookup` (`id`) ON DELETE CASCADE, |
| 17 | 41 | ADD CONSTRAINT `groups_groups_link_ibfk_2` FOREIGN KEY (`member_group_id`) REFERENCES `groups_lookup` (`id`) ON DELETE CASCADE; |
| 18 | 42 | |
| 43 | + | |
| 19 | 44 | -- PREPARE FOR ADDING CONSTRAINTS ON `users_groups_link` |
| 20 | 45 | |
| 21 | 46 | -- group_id |
| 22 | - | |
| 23 | -DELETE FROM `users_groups_link` as ug USING `users_groups_link` as ug, groups_lookup | |
| 24 | - WHERE not exists(select 1 from `groups_lookup` as g where ug.group_id = g.id); | |
| 47 | +CREATE TEMPORARY TABLE cleanup ( | |
| 48 | + `id` int(11) NOT NULL auto_increment, | |
| 49 | + `user_id` int(11) NOT NULL default '0', | |
| 50 | + `group_id` int(11) NOT NULL default '0', | |
| 51 | + PRIMARY KEY (`id`), | |
| 52 | + KEY `user_id` (`user_id`), | |
| 53 | + KEY `group_id` (`group_id`) | |
| 54 | +); | |
| 55 | +INSERT INTO cleanup (id, user_id, group_id) | |
| 56 | +SELECT * FROM `users_groups_link` AS ug WHERE ( SELECT 1 FROM `groups_lookup` AS g WHERE ug.group_id = g.id); | |
| 57 | +SELECT * FROM cleanup; | |
| 58 | +TRUNCATE groups_groups_link; | |
| 59 | +INSERT groups_groups_link SELECT * FROM cleanup; | |
| 60 | +DROP TABLE cleanup; | |
| 25 | 61 | |
| 26 | 62 | -- user_id |
| 27 | - | |
| 28 | -DELETE FROM `users_groups_link` as ug USING `users_groups_link` as ug, users | |
| 29 | - WHERE not exists(select 1 from `users` as u where ug.user_id = u.id); | |
| 63 | +CREATE TEMPORARY TABLE cleanup ( | |
| 64 | + `id` int(11) NOT NULL auto_increment, | |
| 65 | + `user_id` int(11) NOT NULL default '0', | |
| 66 | + `group_id` int(11) NOT NULL default '0', | |
| 67 | + PRIMARY KEY (`id`), | |
| 68 | + KEY `user_id` (`user_id`), | |
| 69 | + KEY `group_id` (`group_id`) | |
| 70 | +); | |
| 71 | +INSERT INTO cleanup (id, user_id, group_id) | |
| 72 | +SELECT * FROM `users_groups_link` AS ug WHERE ( SELECT 1 FROM `groups_lookup` AS g WHERE ug.user_id = g.id); | |
| 73 | +SELECT * FROM cleanup; | |
| 74 | +TRUNCATE groups_groups_link; | |
| 75 | +INSERT groups_groups_link SELECT * FROM cleanup; | |
| 76 | +DROP TABLE cleanup; | |
| 30 | 77 | |
| 31 | 78 | -- ADD CONSTRAINT |
| 32 | 79 | |
| 33 | 80 | ALTER TABLE `users_groups_link` |
| 34 | 81 | ADD CONSTRAINT `users_groups_link_ibfk_1` FOREIGN KEY (`group_id`) REFERENCES `groups_lookup` (`id`) ON DELETE CASCADE, |
| 35 | - ADD CONSTRAINT `users_groups_link_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE; | |
| 82 | + ADD CONSTRAINT `users_groups_link_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE; | |
| 36 | 83 | ... | ... |
templates/ktcore/search2/adv_query_builder.smarty
templates/ktcore/search2/search_results.smarty
| ... | ... | @@ -156,10 +156,10 @@ function onShowAll(showall) |
| 156 | 156 | <span class="contenttype {$hit->MimeIconPath}"> |
| 157 | 157 | |
| 158 | 158 | {if $hit->IsDocument} |
| 159 | - <a href="{$rootUrl}/view.php?fDocumentId={$hit->Id}"><B>{$hit->Title|mb_truncate:30:'...':true}</b></a> | |
| 159 | + <a href="{$rootUrl}/view.php?fDocumentId={$hit->Id}" title="{$hit->Title}"><B>{$hit->Title|mb_truncate:80:'...':true}</b></a> | |
| 160 | 160 | {if $hit->Title != $hit->Filename} |
| 161 | - | |
| 162 | - <font style=" color: green "> - {i18n}Filename:{/i18n} {$hit->Filename|mb_truncate:30:'...':true}</font> | |
| 161 | + <br/> | |
| 162 | + <font style=" color: green ">{i18n}Filename:{/i18n} {$hit->Filename|mb_truncate:80:'...':true}</font> | |
| 163 | 163 | {/if} |
| 164 | 164 | {if $hit->IsAvailable} |
| 165 | 165 | | ... | ... |
tests/api/testElectronicSignatures.php
0 โ 100644
| 1 | +<?php | |
| 2 | +require_once (KT_DIR . '/tests/test.php'); | |
| 3 | +require_once (KT_DIR . '/ktapi/ktapi.inc.php'); | |
| 4 | + | |
| 5 | +/** | |
| 6 | +* These are the unit tests for the main KTAPI class | |
| 7 | +* | |
| 8 | +*/ | |
| 9 | +class APIElectronicSignaturesTestCase extends KTUnitTestCase { | |
| 10 | + | |
| 11 | + /** | |
| 12 | + * @var object $ktapi The main ktapi object | |
| 13 | + */ | |
| 14 | + var $ktapi; | |
| 15 | + | |
| 16 | + /** | |
| 17 | + * @var object $session The KT session object | |
| 18 | + */ | |
| 19 | + var $session; | |
| 20 | + | |
| 21 | + /** | |
| 22 | + * @var object $root The KT folder object | |
| 23 | + */ | |
| 24 | + var $root; | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * @var bool $esig_enabled True if electronic signatures for api are enabled | False if not enabled | |
| 28 | + */ | |
| 29 | + var $esig_enabled; | |
| 30 | + | |
| 31 | + /** | |
| 32 | + * This method sets up the KT session | |
| 33 | + * | |
| 34 | + */ | |
| 35 | + public function setUp() { | |
| 36 | + $this->ktapi = new KTAPI(); | |
| 37 | + $this->session = $this->ktapi->start_session('admin', 'admin'); | |
| 38 | + $this->root = $this->ktapi->get_root_folder(); | |
| 39 | + $this->assertTrue($this->root instanceof KTAPI_Folder); | |
| 40 | + $this->esig_enabled = $this->ktapi->electronic_sig_enabled(); | |
| 41 | + $this->assertTrue($this->esig_enabled); | |
| 42 | + } | |
| 43 | + | |
| 44 | + /** | |
| 45 | + * This method emds the KT session | |
| 46 | + * | |
| 47 | + */ | |
| 48 | + public function tearDown() { | |
| 49 | + $this->session->logout(); | |
| 50 | + } | |
| 51 | + | |
| 52 | + /* *** Test webservice functions *** */ | |
| 53 | + | |
| 54 | + /** | |
| 55 | + * Testing folder creation and deletion, add document, get folder contents, folder detail | |
| 56 | + * Folder shortcuts and actions | |
| 57 | + */ | |
| 58 | + public function testFolderApiFunctions() | |
| 59 | + { | |
| 60 | + // Create a folder | |
| 61 | + // test without authentication - should fail | |
| 62 | + $result1 = $this->ktapi->create_folder(1, 'New test api folder'); | |
| 63 | + $this->assertEqual($result1['status_code'], 1); | |
| 64 | + | |
| 65 | + // test with authentication | |
| 66 | + $result2 = $this->ktapi->create_folder(1, 'New test api folder', 'admin', 'admin', 'Testing API'); | |
| 67 | + $folder_id = $result2['results']['id']; | |
| 68 | + $this->assertEqual($result2['status_code'], 0); | |
| 69 | + $this->assertTrue($result2['results']['parent_id'] == 1); | |
| 70 | + | |
| 71 | + // Create a sub folder | |
| 72 | + // test without authentication - should fail | |
| 73 | + $result3 = $this->ktapi->create_folder($folder_id, 'New test api sub-folder'); | |
| 74 | + $this->assertEqual($result3['status_code'], 1); | |
| 75 | + | |
| 76 | + // test with authentication | |
| 77 | + $result4 = $this->ktapi->create_folder($folder_id, 'New test api sub-folder', 'admin', 'admin', 'Testing API'); | |
| 78 | + $folder_id2 = $result4['results']['id']; | |
| 79 | + $this->assertEqual($result4['status_code'], 0); | |
| 80 | + | |
| 81 | + // Add a document | |
| 82 | + global $default; | |
| 83 | + $dir = $default->uploadDirectory; | |
| 84 | + $tempfilename = $this->createRandomFile('some text', $dir); | |
| 85 | + | |
| 86 | + // test without authentication - should fail | |
| 87 | + $doc = $this->ktapi->add_document($folder_id, 'New API test doc', 'testdoc1.txt', 'Default', $tempfilename); | |
| 88 | + $this->assertEqual($doc['status_code'], 1); | |
| 89 | + | |
| 90 | + // test with authentication | |
| 91 | + $doc = $this->ktapi->add_document($folder_id, 'New API test doc', 'testdoc1.txt', 'Default', $tempfilename, | |
| 92 | + 'admin', 'admin', 'Testing API'); | |
| 93 | + $this->assertEqual($doc['status_code'], 0); | |
| 94 | + $doc_id = $doc['results']['document_id']; | |
| 95 | + $this->assertEqual($doc['results']['title'], 'New API test doc'); | |
| 96 | + | |
| 97 | + // Rename the folder | |
| 98 | + // test without authentication - should fail | |
| 99 | + $renamed = $this->ktapi->rename_folder($folder_id, 'Renamed test folder'); | |
| 100 | + $this->assertEqual($renamed['status_code'], 1); | |
| 101 | + | |
| 102 | + // test with authentication | |
| 103 | + $renamed = $this->ktapi->rename_folder($folder_id, 'Renamed test folder', 'admin', 'admin', 'Testing API'); | |
| 104 | + $this->assertEqual($renamed['status_code'], 0); | |
| 105 | + | |
| 106 | + /** | |
| 107 | + * Copy and move appear to fail in other parts of the code, so only going to test failure here | |
| 108 | + * | |
| 109 | + * Must be VERY careful here with skipping the valid submissions, 3 failed auth attempts in a row locks out the user! | |
| 110 | + */ | |
| 111 | + // Copy folder | |
| 112 | + // test without authentication - should fail | |
| 113 | + $copied = $this->ktapi->copy_folder($source_id, $target_id, $reason); | |
| 114 | + $this->assertEqual($copied['status_code'], 1); | |
| 115 | + | |
| 116 | +// // test with authentication | |
| 117 | +// $copied = $this->ktapi->copy_folder($source_id, $target_id, $reason, 'admin', 'admin'); | |
| 118 | +// echo $copied['status_code']."sd<BR>"; | |
| 119 | +// $this->assertEqual($copied['status_code'], 0); | |
| 120 | + | |
| 121 | + // Move folder | |
| 122 | + // test without authentication - should fail | |
| 123 | + $moved = $this->ktapi->move_folder($source_id, $target_id, $reason); | |
| 124 | + $this->assertEqual($moved['status_code'], 1); | |
| 125 | + | |
| 126 | + // before we end up with 3 fails in a row (see note above the first copy attempt,) force a successful auth | |
| 127 | + $renamed = $this->ktapi->rename_folder($folder_id, 'A New Name', 'admin', 'admin', 'Testing API'); | |
| 128 | + | |
| 129 | +// // test with authentication | |
| 130 | +// $moved = $this->ktapi->move_folder($source_id, $target_id, $reason, 'admin', 'admin'); | |
| 131 | +// $this->assertEqual($moved['status_code'], 0); | |
| 132 | + | |
| 133 | + // before we end up with 3 fails in a row (see note above the first copy attempt,) force a successful auth | |
| 134 | + $renamed = $this->ktapi->rename_folder($folder_id, 'A New Name', 'admin', 'admin', 'Testing API'); | |
| 135 | + | |
| 136 | + // Clean up - delete the folder | |
| 137 | + // test without authentication - should fail | |
| 138 | + $deleted = $this->ktapi->delete_folder($folder_id, 'Testing API'); | |
| 139 | + $this->assertEqual($deleted['status_code'], 1); | |
| 140 | + | |
| 141 | + // test with authentication | |
| 142 | + $deleted = $this->ktapi->delete_folder($folder_id, 'Testing API', 'admin', 'admin'); | |
| 143 | + $this->assertEqual($deleted['status_code'], 0); | |
| 144 | + } | |
| 145 | + | |
| 146 | + /** | |
| 147 | + * Testing document get, update, actions, delete, shortcuts and detail | |
| 148 | + */ | |
| 149 | + public function testDocumentApiFunctions() | |
| 150 | + { | |
| 151 | + // Create a folder | |
| 152 | + // test without authentication - should fail | |
| 153 | + $result1 = $this->ktapi->create_folder(1, 'New test api folder'); | |
| 154 | + $this->assertEqual($result1['status_code'], 1); | |
| 155 | + | |
| 156 | + // test with authentication | |
| 157 | + $result2 = $this->ktapi->create_folder(1, 'New test api folder', 'admin', 'admin', 'Testing API'); | |
| 158 | + $folder_id = $result2['results']['id']; | |
| 159 | + $this->assertEqual($result2['status_code'], 0); | |
| 160 | + | |
| 161 | + // Create a sub folder | |
| 162 | + // test without authentication - should fail | |
| 163 | + $result3 = $this->ktapi->create_folder($folder_id, 'New test api sub-folder'); | |
| 164 | + $this->assertEqual($result3['status_code'], 1); | |
| 165 | + | |
| 166 | + // test with authentication | |
| 167 | + $result4 = $this->ktapi->create_folder($folder_id, 'New test api sub-folder', 'admin', 'admin', 'Testing API'); | |
| 168 | + $folder_id2 = $result4['results']['id']; | |
| 169 | + $this->assertEqual($result4['status_code'], 0); | |
| 170 | + | |
| 171 | + // Add a document | |
| 172 | + global $default; | |
| 173 | + $dir = $default->uploadDirectory; | |
| 174 | + $tempfilename = $this->createRandomFile('some text', $dir); | |
| 175 | + | |
| 176 | + // test without authentication - should fail | |
| 177 | + $doc = $this->ktapi->add_document($folder_id, 'New API test doc', 'testdoc1.txt', 'Default', $tempfilename); | |
| 178 | + $this->assertEqual($doc['status_code'], 1); | |
| 179 | + | |
| 180 | + // test with authentication | |
| 181 | + $doc = $this->ktapi->add_document($folder_id, 'New API test doc', 'testdoc1.txt', 'Default', $tempfilename, | |
| 182 | + 'admin', 'admin', 'Testing API'); | |
| 183 | + $this->assertEqual($doc['status_code'], 0); | |
| 184 | + $doc_id = $doc['results']['document_id']; | |
| 185 | + | |
| 186 | + // Checkout the document | |
| 187 | + // test without authentication - should fail | |
| 188 | + $result1 = $this->ktapi->checkout_document($doc_id, 'Testing API', true); | |
| 189 | + $this->assertEqual($result1['status_code'], 1); | |
| 190 | + | |
| 191 | + // test with authentication | |
| 192 | + $result2 = $this->ktapi->checkout_document($doc_id, 'Testing API', true, 'admin', 'admin'); | |
| 193 | + $this->assertEqual($doc['status_code'], 0); | |
| 194 | + $this->assertTrue(!empty($result2['results'])); | |
| 195 | + | |
| 196 | + // Checkin the document | |
| 197 | + $dir = $default->uploadDirectory; | |
| 198 | + $tempfilename = $this->createRandomFile('some text', $dir); | |
| 199 | + // test without authentication - should fail | |
| 200 | + $result3 = $this->ktapi->checkin_document($doc_id, 'testdoc1.txt', 'Testing API', $tempfilename, false); | |
| 201 | + $this->assertEqual($result3['status_code'], 1); | |
| 202 | + | |
| 203 | + // test with authentication | |
| 204 | + $result4 = $this->ktapi->checkin_document($doc_id, 'testdoc1.txt', 'Testing API', $tempfilename, false, 'admin', 'admin'); | |
| 205 | + $this->assertEqual($result4['status_code'], 0); | |
| 206 | + $this->assertEqual($result4['results']['document_id'], $doc_id); | |
| 207 | + | |
| 208 | + // Delete the document | |
| 209 | + // test without authentication - should fail | |
| 210 | + $result5 = $this->ktapi->delete_document($doc_id, 'Testing API'); | |
| 211 | + $this->assertEqual($result5['status_code'], 1); | |
| 212 | + | |
| 213 | + // test with authentication | |
| 214 | + $result6 = $this->ktapi->delete_document($doc_id, 'Testing API', 'admin', 'admin', true); | |
| 215 | + $this->assertEqual($result6['status_code'], 0); | |
| 216 | + | |
| 217 | + // Clean up - delete the folder | |
| 218 | + // test without authentication - should fail | |
| 219 | + $result7 = $this->ktapi->delete_folder($folder_id, 'Testing API'); | |
| 220 | + $this->assertEqual($result7['status_code'], 1); | |
| 221 | + | |
| 222 | + $result8 = $this->ktapi->delete_folder($folder_id, 'Testing API', 'admin', 'admin'); | |
| 223 | + $this->assertEqual($result8['status_code'], 0); | |
| 224 | + } | |
| 225 | + | |
| 226 | + /** | |
| 227 | + * Helper function to create a document | |
| 228 | + */ | |
| 229 | + function createDocument($title, $filename, $folder = null) | |
| 230 | + { | |
| 231 | + if(is_null($folder)){ | |
| 232 | + $folder = $this->root; | |
| 233 | + } | |
| 234 | + | |
| 235 | + // Create a new document | |
| 236 | + $randomFile = $this->createRandomFile(); | |
| 237 | + $this->assertTrue(is_file($randomFile)); | |
| 238 | + | |
| 239 | + if ($this->esig_enabled) | |
| 240 | + { | |
| 241 | + $document = $folder->add_document($title, $filename, 'Default', $randomFile, 'admin', 'admin', 'Testing API'); | |
| 242 | + } | |
| 243 | + else | |
| 244 | + { | |
| 245 | + $document = $folder->add_document($title, $filename, 'Default', $randomFile); | |
| 246 | + } | |
| 247 | + $this->assertNotError($document); | |
| 248 | + | |
| 249 | + @unlink($randomFile); | |
| 250 | + if(PEAR::isError($document)) return false; | |
| 251 | + | |
| 252 | + return $document; | |
| 253 | + } | |
| 254 | + | |
| 255 | + /** | |
| 256 | + * Helper function to delete docs | |
| 257 | + */ | |
| 258 | + function deleteDocument($document) | |
| 259 | + { | |
| 260 | + $document->delete('Testing API'); | |
| 261 | + $document->expunge(); | |
| 262 | + } | |
| 263 | + | |
| 264 | + function createRandomFile($content = 'this is some text', $uploadDir = null) { | |
| 265 | + if(is_null($uploadDir)){ | |
| 266 | + $uploadDir = dirname(__FILE__); | |
| 267 | + } | |
| 268 | + $temp = tempnam($uploadDir, 'myfile'); | |
| 269 | + $fp = fopen($temp, 'wt'); | |
| 270 | + fwrite($fp, $content); | |
| 271 | + fclose($fp); | |
| 272 | + return $temp; | |
| 273 | + } | |
| 274 | +} | |
| 275 | +?> | |
| 0 | 276 | \ No newline at end of file | ... | ... |
tests/runtests.php
| ... | ... | @@ -8,6 +8,9 @@ class UnitTests extends TestSuite { |
| 8 | 8 | $this->TestSuite('Unit tests'); |
| 9 | 9 | |
| 10 | 10 | // KTAPI |
| 11 | + // Some of these tests will fail if Electronic Signatures are enabled for the API. | |
| 12 | + // To fix, check the failing functions and add 'admin', 'admin' as username and password, | |
| 13 | + // and where necessary send 'Testing API' as a reason | |
| 11 | 14 | $this->addFile('api/testApi.php'); |
| 12 | 15 | $this->addFile('api/testAuto.php'); |
| 13 | 16 | $this->addFile('api/testSavedSearches.php'); |
| ... | ... | @@ -17,6 +20,8 @@ class UnitTests extends TestSuite { |
| 17 | 20 | $this->addFile('api/testFolder.php'); |
| 18 | 21 | $this->addFile('api/testBulkActions.php'); |
| 19 | 22 | $this->addFile('api/testCollection.php'); |
| 23 | + // Only activate this test if Electronic Signatures are enabled for the API | |
| 24 | +// $this->addFile('api/testElectronicSignatures.php'); | |
| 20 | 25 | |
| 21 | 26 | // $this->addFile('SQLFile/test_sqlfile.php'); |
| 22 | 27 | // $this->addFile('cache/testCache.php'); |
| ... | ... | @@ -28,9 +33,9 @@ class UnitTests extends TestSuite { |
| 28 | 33 | // $this->addFile('filelike/testStringFileLike.php'); |
| 29 | 34 | |
| 30 | 35 | // Search (2) and indexing |
| 31 | - $this->addFile('documentProcessor/testExtracters.php'); | |
| 32 | - $this->addFile('documentProcessor/testGuidInserter.php'); | |
| 33 | - $this->addFile('search2/testSearch.php'); | |
| 36 | +// $this->addFile('documentProcessor/testExtracters.php'); | |
| 37 | +// $this->addFile('documentProcessor/testGuidInserter.php'); | |
| 38 | +// $this->addFile('search2/testSearch.php'); | |
| 34 | 39 | } |
| 35 | 40 | } |
| 36 | 41 | ... | ... |