Commit dcf92b7acf69c3770a76705d0cb4e1f6a05e1c88
1 parent
054d76c3
Allow for the setting and getting of the groups/users/roles that get
informed when a particular workflow state is entered. git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3883 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
31 additions
and
0 deletions
lib/workflow/workflowutil.inc.php
| ... | ... | @@ -4,6 +4,7 @@ require_once(KT_LIB_DIR . '/workflow/workflow.inc.php'); |
| 4 | 4 | require_once(KT_LIB_DIR . '/workflow/workflowstate.inc.php'); |
| 5 | 5 | require_once(KT_LIB_DIR . '/workflow/workflowtransition.inc.php'); |
| 6 | 6 | |
| 7 | +require_once(KT_LIB_DIR . '/permissions/permissionutil.inc.php'); | |
| 7 | 8 | require_once(KT_LIB_DIR . '/groups/GroupUtil.php'); |
| 8 | 9 | |
| 9 | 10 | class KTWorkflowUtil { |
| ... | ... | @@ -242,5 +243,35 @@ class KTWorkflowUtil { |
| 242 | 243 | ); |
| 243 | 244 | return DBUtil::runQuery($aQuery); |
| 244 | 245 | } |
| 246 | + | |
| 247 | + // {{{ setInformedForState | |
| 248 | + /** | |
| 249 | + * Sets the users/groups/roles informed when a state is arrived at. | |
| 250 | + */ | |
| 251 | + function setInformedForState(&$oState, $aInformed) { | |
| 252 | + $oDescriptor =& KTPermissionUtil::getOrCreateDescriptor($aInformed); | |
| 253 | + if (PEAR::isError($oDescriptor)) { | |
| 254 | + return $oDescriptor; | |
| 255 | + } | |
| 256 | + $iOldDescriptorId = $oState->getInformDescriptorId(); | |
| 257 | + $oState->setInformDescriptorId($oDescriptor->getId()); | |
| 258 | + $res = $oState->update(); | |
| 259 | + if (PEAR::isError($res)) { | |
| 260 | + $oState->setInformDescriptorId($iOldDescriptorId); | |
| 261 | + return $res; | |
| 262 | + } | |
| 263 | + return $res; | |
| 264 | + } | |
| 265 | + // }}} | |
| 266 | + | |
| 267 | + // {{{ getInformedForState | |
| 268 | + function getInformedForState($oState) { | |
| 269 | + $iDescriptorId = $oState->getInformDescriptorId(); | |
| 270 | + if (empty($iDescriptorId)) { | |
| 271 | + return array(); | |
| 272 | + } | |
| 273 | + return KTPermissionUtil::getAllowedForDescriptor($iDescriptorId); | |
| 274 | + } | |
| 275 | + // }}} | |
| 245 | 276 | } |
| 246 | 277 | ... | ... |