Commit 3cc3a1853cdf3c585cc16207c9bc3d42e5b4eac6
1 parent
0bbabb0d
KTS-3548
"My Drop Documents plugin references commercial plugin function." Fixed. Copied referenced fuction to local function. Committed By: Kevin Fourie Reviewed By: Conrad Vermeulen git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@8942 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
60 additions
and
1 deletions
plugins/MyDropDocumentsPlugin/MyDropDocumentsPage.php
| ... | ... | @@ -36,12 +36,12 @@ |
| 36 | 36 | * |
| 37 | 37 | */ |
| 38 | 38 | |
| 39 | +require_once("config/dmsDefaults.php"); | |
| 39 | 40 | require_once(KT_DIR . "/ktapi/ktapi.inc.php"); |
| 40 | 41 | require_once(KT_LIB_DIR . "/plugins/plugin.inc.php"); |
| 41 | 42 | require_once(KT_LIB_DIR . "/plugins/pluginregistry.inc.php"); |
| 42 | 43 | require_once(KT_LIB_DIR . "/dashboard/dashlet.inc.php"); |
| 43 | 44 | require_once(KT_DIR . "/plugins/ktcore/KTFolderActions.php"); |
| 44 | -require_once(KT_DIR . "/plugins/network/extendedtransactioninfo/simpletransactionutil.inc.php"); | |
| 45 | 45 | require_once(KT_DIR . "/ktapi/KTAPIFolder.inc.php"); |
| 46 | 46 | require_once(KT_LIB_DIR . "/roles/Role.inc"); |
| 47 | 47 | require_once(KT_LIB_DIR . "/roles/roleallocation.inc.php"); |
| ... | ... | @@ -655,5 +655,64 @@ class MyDropDocumentsPage extends KTStandardDispatcher { |
| 655 | 655 | } |
| 656 | 656 | } |
| 657 | 657 | |
| 658 | + /* | |
| 659 | + attempt to abstract the transaction-matching query. | |
| 660 | + | |
| 661 | + tables that are already defined (other than sec ones): | |
| 662 | + | |
| 663 | + - Documents (D) | |
| 664 | + - Users (U) | |
| 665 | + - TransactionTypes (DTT) | |
| 666 | + - Document Transactions (DT) | |
| 667 | + | |
| 668 | + so where clausess can take advantage of those. | |
| 669 | + | |
| 670 | + */ | |
| 671 | + function getTransactionsMatchingQuery($oUser, $sJoinClause, $aExternalWhereClauses, $aExternalWhereParams, $aOptions = null) { | |
| 672 | + | |
| 673 | + $sSelectItems = 'DTT.name AS transaction_name, U.name AS user_name, DT.version AS version, DT.comment AS comment, DT.datetime AS datetime, D.id as document_id, DT.transaction_namespace as namespace'; | |
| 674 | + $sBaseJoin = "FROM " . KTUtil::getTableName("document_transactions") . " AS DT " . | |
| 675 | + "INNER JOIN " . KTUtil::getTableName("users") . " AS U ON DT.user_id = U.id " . | |
| 676 | + "INNER JOIN " . KTUtil::getTableName("transaction_types") . " AS DTT ON DTT.namespace = DT.transaction_namespace " . | |
| 677 | + "INNER JOIN " . KTUtil::getTableName("documents") . " AS D ON D.id = DT.document_id "; | |
| 678 | + | |
| 679 | + // now we're almost at partialquery like status. | |
| 680 | + $perm_res = KTSearchUtil::permissionToSQL($oUser, 'ktcore.permissions.read'); | |
| 681 | + if (PEAR::isError($perm_res)) { | |
| 682 | + return $perm_res; | |
| 683 | + } | |
| 684 | + list($sPermissionString, $aPermissionParams, $sPermissionJoin) = $perm_res; | |
| 685 | + | |
| 686 | + // compile the final list | |
| 687 | + $aFinalWhere = kt_array_merge(array($sPermissionString,'D.creator_id IS NOT NULL'), $aExternalWhereClauses, array('D.status_id = ?')); | |
| 688 | + $aFinalWhereParams = kt_array_merge($aPermissionParams, $aExternalWhereParams, array(LIVE)); | |
| 689 | + | |
| 690 | + if (!is_array($aOptions)) { | |
| 691 | + $aOptions = (array) $aOptions; | |
| 692 | + } | |
| 693 | + $sOrderBy = KTUtil::arrayGet($aOptions, 'orderby', 'DT.datetime DESC'); | |
| 694 | + | |
| 695 | + // compile these. | |
| 696 | + // NBM: do we need to wrap these in ()? | |
| 697 | + $sWhereClause = implode(' AND ', $aFinalWhere); | |
| 698 | + if (!empty($sWhereClause)) { | |
| 699 | + $sWhereClause = 'WHERE ' . $sWhereClause; | |
| 700 | + } | |
| 701 | + | |
| 702 | + $sQuery = sprintf("SELECT %s %s %s %s %s ORDER BY %s", | |
| 703 | + $sSelectItems, | |
| 704 | + $sBaseJoin, | |
| 705 | + $sPermissionJoin, | |
| 706 | + $sJoinClause, | |
| 707 | + $sWhereClause, | |
| 708 | + $sOrderBy | |
| 709 | + ); | |
| 710 | + | |
| 711 | + //var_dump(array($sQuery, $aFinalWhereParams)); | |
| 712 | + | |
| 713 | + $res = DBUtil::getResultArray(array($sQuery, $aFinalWhereParams)); | |
| 714 | + //var_dump($res); exit(0); | |
| 715 | + return $res; | |
| 716 | + } | |
| 658 | 717 | } |
| 659 | 718 | ?> | ... | ... |