Commit 051bf8c4d866191f7843343190f9bbe3bd684b7a

Authored by Neil Blakey-Milner
1 parent e605ffa6

Add transactions on role allocation changes


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5244 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/foldermanagement/foldertransaction.inc.php
@@ -45,6 +45,13 @@ class KTFolderTransaction extends KTEntity { @@ -45,6 +45,13 @@ class KTFolderTransaction extends KTEntity {
45 return KTUtil::getTableName('folder_transactions'); 45 return KTUtil::getTableName('folder_transactions');
46 } 46 }
47 47
  48 + function _fieldValues() {
  49 + if (empty($this->dDateTime)) {
  50 + $this->dDateTime = getCurrentDateTime();
  51 + }
  52 + return parent::_fieldValues();
  53 + }
  54 +
48 // STATIC 55 // STATIC
49 function &get($iId) { 56 function &get($iId) {
50 return KTEntityUtil::get('KTFolderTransaction', $iId); 57 return KTEntityUtil::get('KTFolderTransaction', $iId);
plugins/ktcore/KTPermissions.php
@@ -31,13 +31,14 @@ require_once(KT_LIB_DIR . '/actions/documentaction.inc.php'); @@ -31,13 +31,14 @@ require_once(KT_LIB_DIR . '/actions/documentaction.inc.php');
31 require_once(KT_LIB_DIR . '/widgets/fieldWidgets.php'); 31 require_once(KT_LIB_DIR . '/widgets/fieldWidgets.php');
32 32
33 require_once(KT_LIB_DIR . "/foldermanagement/Folder.inc"); 33 require_once(KT_LIB_DIR . "/foldermanagement/Folder.inc");
  34 +require_once(KT_LIB_DIR . "/foldermanagement/foldertransaction.inc.php");
  35 +
34 require_once(KT_LIB_DIR . "/groups/Group.inc"); 36 require_once(KT_LIB_DIR . "/groups/Group.inc");
35 require_once(KT_LIB_DIR . "/users/User.inc"); 37 require_once(KT_LIB_DIR . "/users/User.inc");
36 require_once(KT_LIB_DIR . "/roles/Role.inc"); 38 require_once(KT_LIB_DIR . "/roles/Role.inc");
37 require_once(KT_LIB_DIR . "/roles/roleallocation.inc.php"); 39 require_once(KT_LIB_DIR . "/roles/roleallocation.inc.php");
38 require_once(KT_LIB_DIR . "/roles/documentroleallocation.inc.php"); 40 require_once(KT_LIB_DIR . "/roles/documentroleallocation.inc.php");
39 41
40 -  
41 require_once(KT_LIB_DIR . "/permissions/permission.inc.php"); 42 require_once(KT_LIB_DIR . "/permissions/permission.inc.php");
42 require_once(KT_LIB_DIR . "/permissions/permissionobject.inc.php"); 43 require_once(KT_LIB_DIR . "/permissions/permissionobject.inc.php");
43 require_once(KT_LIB_DIR . "/permissions/permissionlookup.inc.php"); 44 require_once(KT_LIB_DIR . "/permissions/permissionlookup.inc.php");
@@ -283,8 +284,21 @@ class KTRoleAllocationPlugin extends KTFolderAction { @@ -283,8 +284,21 @@ class KTRoleAllocationPlugin extends KTFolderAction {
283 $this->errorRedirectToMain(_kt('Failed to create the role allocation.') . print_r($res, true), sprintf('fFolderId=%d', $this->oFolder->getId())); 284 $this->errorRedirectToMain(_kt('Failed to create the role allocation.') . print_r($res, true), sprintf('fFolderId=%d', $this->oFolder->getId()));
284 } 285 }
285 286
286 - $this->renegeratePermissionsForRole($oRoleAllocation->getRoleId()); 287 + $oTransaction = KTFolderTransaction::createFromArray(array(
  288 + 'folderid' => $this->oFolder->getId(),
  289 + 'comment' => "Override parent allocation",
  290 + 'transactionNS' => 'ktcore.transactions.role_allocations_change',
  291 + 'userid' => $_SESSION['userID'],
  292 + 'ip' => Session::getClientIP(),
  293 + ));
  294 + $aOptions = array(
  295 + 'defaultmessage' => _kt('Error creating allocation'),
  296 + 'redirect_to' => array('main', sprintf('fFolderId=%d', $this->oFolder->getId())),
  297 + );
  298 + $this->oValidator->notErrorFalse($oTransaction, $aOptions);
287 299
  300 + $this->renegeratePermissionsForRole($oRoleAllocation->getRoleId());
  301 +
288 $this->successRedirectToMain(_kt('Role allocation created.'), sprintf('fFolderId=%d', $this->oFolder->getId())); 302 $this->successRedirectToMain(_kt('Role allocation created.'), sprintf('fFolderId=%d', $this->oFolder->getId()));
289 } 303 }
290 304
@@ -310,7 +324,21 @@ class KTRoleAllocationPlugin extends KTFolderAction { @@ -310,7 +324,21 @@ class KTRoleAllocationPlugin extends KTFolderAction {
310 exit(0); 324 exit(0);
311 } 325 }
312 326
  327 + $oTransaction = KTFolderTransaction::createFromArray(array(
  328 + 'folderid' => $this->oFolder->getId(),
  329 + 'comment' => "Use parent allocation",
  330 + 'transactionNS' => 'ktcore.transactions.role_allocations_change',
  331 + 'userid' => $_SESSION['userID'],
  332 + 'ip' => Session::getClientIP(),
  333 + ));
  334 + $aOptions = array(
  335 + 'defaultmessage' => _kt('Problem assigning role to parent allocation'),
  336 + 'redirect_to' => array('main', sprintf('fFolderId=%d', $this->oFolder->getId())),
  337 + );
  338 + $this->oValidator->notErrorFalse($oTransaction, $aOptions);
  339 +
313 $this->renegeratePermissionsForRole($oRoleAllocation->getRoleId()); 340 $this->renegeratePermissionsForRole($oRoleAllocation->getRoleId());
  341 +
314 $this->successRedirectToMain(_kt('Role now uses parent.'), sprintf('fFolderId=%d',$this->oFolder->getId())); 342 $this->successRedirectToMain(_kt('Role now uses parent.'), sprintf('fFolderId=%d',$this->oFolder->getId()));
315 } 343 }
316 344
@@ -443,6 +471,19 @@ class KTRoleAllocationPlugin extends KTFolderAction { @@ -443,6 +471,19 @@ class KTRoleAllocationPlugin extends KTFolderAction {
443 $this->errorRedirectToMain(_kt('Failed to change the role allocation.') . print_r($res, true), sprintf('fFolderId=%d', $this->oFolder->getId())); 471 $this->errorRedirectToMain(_kt('Failed to change the role allocation.') . print_r($res, true), sprintf('fFolderId=%d', $this->oFolder->getId()));
444 } 472 }
445 473
  474 + $oTransaction = KTFolderTransaction::createFromArray(array(
  475 + 'folderid' => $this->oFolder->getId(),
  476 + 'comment' => "Set role users",
  477 + 'transactionNS' => 'ktcore.transactions.role_allocations_change',
  478 + 'userid' => $_SESSION['userID'],
  479 + 'ip' => Session::getClientIP(),
  480 + ));
  481 + $aOptions = array(
  482 + 'defaultmessage' => _kt('Problem assigning role users'),
  483 + 'redirect_to' => array('main', sprintf('fFolderId=%d', $this->oFolder->getId())),
  484 + );
  485 + $this->oValidator->notErrorFalse($oTransaction, $aOptions);
  486 +
446 $this->renegeratePermissionsForRole($oRoleAllocation->getRoleId()); 487 $this->renegeratePermissionsForRole($oRoleAllocation->getRoleId());
447 488
448 $this->successRedirectToMain(_kt('Allocation changed.'), sprintf('fFolderId=%d',$this->oFolder->getId())); 489 $this->successRedirectToMain(_kt('Allocation changed.'), sprintf('fFolderId=%d',$this->oFolder->getId()));
@@ -485,6 +526,19 @@ class KTRoleAllocationPlugin extends KTFolderAction { @@ -485,6 +526,19 @@ class KTRoleAllocationPlugin extends KTFolderAction {
485 $this->errorRedirectToMain(_kt('Failed to change the role allocation.') . print_r($res, true), sprintf('fFolderId=%d', $this->oFolder->getId())); 526 $this->errorRedirectToMain(_kt('Failed to change the role allocation.') . print_r($res, true), sprintf('fFolderId=%d', $this->oFolder->getId()));
486 } 527 }
487 528
  529 + $oTransaction = KTFolderTransaction::createFromArray(array(
  530 + 'folderid' => $this->oFolder->getId(),
  531 + 'comment' => "Set role groups",
  532 + 'transactionNS' => 'ktcore.transactions.role_allocations_change',
  533 + 'userid' => $_SESSION['userID'],
  534 + 'ip' => Session::getClientIP(),
  535 + ));
  536 + $aOptions = array(
  537 + 'defaultmessage' => _kt('Problem assigning role groups'),
  538 + 'redirect_to' => array('main', sprintf('fFolderId=%d', $this->oFolder->getId())),
  539 + );
  540 + $this->oValidator->notErrorFalse($oTransaction, $aOptions);
  541 +
488 $this->renegeratePermissionsForRole($oRoleAllocation->getRoleId()); 542 $this->renegeratePermissionsForRole($oRoleAllocation->getRoleId());
489 543
490 $this->successRedirectToMain(_kt('Allocation changed.'), sprintf('fFolderId=%d',$this->oFolder->getId())); 544 $this->successRedirectToMain(_kt('Allocation changed.'), sprintf('fFolderId=%d',$this->oFolder->getId()));