comanage-dev - Re: [comanage-dev] change to CoPeopleController.php necessary for Grouper backend
Subject: COmanage Developers List
List archive
Re: [comanage-dev] change to CoPeopleController.php necessary for Grouper backend
Chronological Thread
- From: Benn Oshrin <>
- To:
- Subject: Re: [comanage-dev] change to CoPeopleController.php necessary for Grouper backend
- Date: Thu, 13 Sep 2012 17:35:22 -0400
Actually, never mind. It won't cascade a delete.
On 9/13/12 5:33 PM, Benn Oshrin wrote:
FYI, after my next major commit CoEnrollmentFlow will also cascade
deletes to CoGroup.
-Benn-
On 9/12/12 12:09 PM, Scott Koranda wrote:
Hi,
As Benn suspected, deleting a CoPerson causes a cascade that
results in CakePHP assuming that the Grouper data source is a
relational database.
To "fix" that problem I want to add a delete() method for the
CoPeopleController.php that dynamically changes the linking
between the models to prevent the cascade from affecting the
CoGroupMembers model.
Here is the proposed code:
/**
* Delete a CoPerson Object. WARNING: this method will delete all
associated data.
* This method calls the StandardController delete() method after
first temporarily changing
* model dependcies if necessary to compensate for data sources
used for groups and group
* memberships that may not use SQL and support cascading deletes.
*
* - precondition: see StandardController
* - postcondition: see StandardController
* - postcondition: see StandardController
*
* @since COmanage Registry v0.8
* @param integer Object identifier (eg: cm_co_groups:id)
representing object to be deleted
*/
function delete($id) {
// Get a pointer to our model
$req = $this->modelClass;
$model = $this->$req;
// If a data store for groups and group memberships is being used
that
// is not a relational database supporting SQL then temporarily
remove
// the model relationship to group memberships.
if (!Configure::read('COmanage.groupSqlDataSource')) {
$groupMembersLinkValue = $model->hasMany['CoGroupMember'];
unset($model->hasMany['CoGroupMember']);
// Use the parent method to do the delete.
$ret = parent::delete($id);
// Restore the model relationship to group memberships if it
was deleted.
$model->hasMany['CoGroupMember'] = $groupMembersLinkValue;
} else {
// Use the parent method to do the delete.
$ret = parent::delete($id);
}
return $ret;
}
What say ye?
Thanks,
Scott
- [comanage-dev] change to CoPeopleController.php necessary for Grouper backend, Scott Koranda, 09/12/2012
- Re: [comanage-dev] change to CoPeopleController.php necessary for Grouper backend, Benn Oshrin, 09/12/2012
- Re: [comanage-dev] change to CoPeopleController.php necessary for Grouper backend, Scott Koranda, 09/12/2012
- Re: [comanage-dev] change to CoPeopleController.php necessary for Grouper backend, Benn Oshrin, 09/13/2012
- Re: [comanage-dev] change to CoPeopleController.php necessary for Grouper backend, Benn Oshrin, 09/13/2012
- Re: [comanage-dev] change to CoPeopleController.php necessary for Grouper backend, Benn Oshrin, 09/12/2012
Archive powered by MHonArc 2.6.16.