Commit 4029952b8cabc5e6204382cf27828dfef6872b2f

Authored by Neil Blakey-Milner
1 parent 019b260d

Add getByState, which finds all documents in a given workflow state.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4804 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/documentmanagement/Document.inc
@@ -305,6 +305,22 @@ class Document { @@ -305,6 +305,22 @@ class Document {
305 } 305 }
306 // }}} 306 // }}}
307 307
  308 + // {{{ getByState
  309 + function &getByState($oState) {
  310 + $iStateId = KTUtil::getId($oState);
  311 + $sTable = KTUtil::getTableName('workflow_documents');
  312 + $sQuery = sprintf('SELECT document_id FROM %s WHERE state_id = ?', $sTable);
  313 + $aParams = array($iStateId);
  314 + $aIds = DBUtil::getResultArrayKey(array($sQuery, $aParams), 'document_id');
  315 +
  316 + $aList = array();
  317 + foreach ($aIds as $iId) {
  318 + $aList[] = Document::get($iId);
  319 + }
  320 + return $aList;
  321 + }
  322 + // }}}
  323 +
308 // STATIC 324 // STATIC
309 function &createFromArray($aOptions) { 325 function &createFromArray($aOptions) {
310 if (KTUtil::arrayGet($aOptions, "size") === null) { 326 if (KTUtil::arrayGet($aOptions, "size") === null) {