Author: david
Date: Thu Sep 17 11:30:50 2009
New Revision: 3371
Log:
Add code to user/edit to create, update and delete user permissions.
Modified:
trunk/apps/qubit/modules/user/actions/editAction.class.php
Modified: trunk/apps/qubit/modules/user/actions/editAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/user/actions/editAction.class.php Thu Sep 17
11:29:04 2009 (r3370)
+++ trunk/apps/qubit/modules/user/actions/editAction.class.php Thu Sep 17
11:30:50 2009 (r3371)
@@ -95,7 +95,9 @@
$this->addField($name);
}
- $this->permissions = $this->user->getAclPermissions();
+ // HACK: because $this->user->getAclPermissions() is erroneously calling
+ // QubitObject::getaclPermissionsById()
+ $this->permissions = QubitUser::getaclPermissionsById($this->user->id,
array('self' => $this));
$this->credentials = $this->user->getUserCredentials();
$this->isAdministrator = false;
@@ -123,6 +125,8 @@
$this->user->save();
$this->updateUserGroups();
+ $this->updatePermissions();
+ $this->deletePermissions();
return $this;
}
@@ -160,4 +164,62 @@
return $this;
}
+
+ protected function updatePermissions()
+ {
+ foreach ($this->request->getParameter('permission') as $key => $formData)
+ {
+ if ('new' == $key)
+ {
+ if (0 < intval($formData['actionId']))
+ {
+ $aclPermission = new QubitAclPermission;
+ $aclPermission->userId = $this->user->id;
+ $aclPermission->actionId = $formData['actionId'];
+ }
+ else
+ {
+ continue;
+ }
+ }
+ else
+ {
+ $aclPermission = QubitAclPermission::getById($key);
+ if (null === $aclPermission)
+ {
+ // If no valid aclPermission object, skip this row
+ continue;
+ }
+ }
+
+ $aclPermission->grantDeny = $formData['grantDeny'];
+
+ // Set repository conditional for permission
+ if ('null' != $formData['repository'])
+ {
+ $params =
$this->context->routing->parse(preg_replace('/.*'.preg_quote($this->request->getPathInfoPrefix(),
'/').'/', null, $formData['repository']));
+ $aclPermission->setRepository(QubitRepository::getById($params['id']));
+ }
+ else
+ {
+ $aclPermission->setRepository(null);
+ }
+
+ $aclPermission->save();
+ }
+ }
+
+ protected function deletePermissions()
+ {
+ if (is_array($deletePermissions =
$this->request->getParameter('deletePermission')))
+ {
+ foreach ($deletePermissions as $key => $value)
+ {
+ if (null !== $permission = QubitAclPermission::getById($key))
+ {
+ $permission->delete();
+ }
+ }
+ }
+ }
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.ca/group/qubit-commits?hl=en
-~----------~----~----~----~------~----~------~--~---