comanage-dev - Re: [comanage-dev] question on COUs and detecting cycle in parent/child
Subject: COmanage Developers List
List archive
- From: Marie Huynh <>
- To: Scott Koranda <>
- Cc: comanage-dev <>
- Subject: Re: [comanage-dev] question on COUs and detecting cycle in parent/child
- Date: Wed, 14 Mar 2012 13:43:54 -0700
Ah, a few things: viewVars should no longer be read from in controllers and the line should be this, with the id of the Cou being edited passed in as the first parameter:
if($this->Cou->isChildCou($reqdata['Cou']['id'], $parentCou))
The array comparison also returns the index of what was found and false when not found, but index can be 0 so comparisons must be type-checked. Thus the function should look like this:
/**
* Check if couNode is a child of couBranch.
*
* @since COmanage Registry v0.3
* @param integer Head of the branch to be searched
* @param integer Node to be looked for
* @return boolean True if child, false otherwise
*/
public function isChildCou($couBranch, $couNode) {
// Get list of all children of $couBranch
$childrenArrays = $this->children($couBranch, false, 'id');
$childrenList = Set::extract($childrenArrays, '{n}.Cou.id');
// Check for NULL to avoid warning/error from array_search (See CO-240)
if(($childrenList != NULL)
&& (array_search($couNode, $childrenList) !== false)) {
// Node was found in the branch
return true;
}
return false;
}
The comment was incorrectly added in after the function was written. Can I commit this?
On Wed, Mar 14, 2012 at 9:41 AM, Scott Koranda <> wrote:
Hi,
CouController.php contains this code:
// Check if parent would cause a loop
if($this->Cou->isChildCou($this->viewVars['cur_co']['Cou']['id'], $parentCou) )
{
if($this->restful)
$this->restResultHeader(403, "Parent Would Create Cycle");
else
$this->Session->setFlash(_txt('er.cou.cycle',
array($reqdata['CoGroupMember']['co_group_id'])), '', array(),
'error');
return(false);
}
I am getting a Cake exception because for the array viewVars
there is no key 'cur_co'.
What precisely should be the first argument to the method
isChildCou()?
The code documentation says
@param Array Head of the branch to be searched
but that is not descriptive enough--an array of what? With
what structure? From where?
Thanks,
Scott
- [comanage-dev] question on COUs and detecting cycle in parent/child, Scott Koranda, 03/14/2012
- Re: [comanage-dev] question on COUs and detecting cycle in parent/child, Marie Huynh, 03/14/2012
Archive powered by MHonArc 2.6.16.