Jump to content

Recommended Posts

Posted

You go to Packages > Groups > select one and move it :P I've had to move the bottom to the top and then move the back into normal, it's just random editing like for me it's only my SSL packages. I have a lot of them.

Posted
It appears that when a package is edited, groups are removed and re-added? If so this should be expected behavior.

 

In edit function:

 


if (isset($vars['groups']))

$this->setGroups($package_id, $vars['groups']);


 

setGroups function:

 

private function setGroups($package_id, $groups=null) {

// Remove all existing groups

$this->Record->from("package_group")->

where("package_id", "=", $package_id)->delete();

 

// Add all given groups

if (!empty($groups) && is_array($groups)) {

for ($i=0; $i<count($groups); $i++) {

$vars = array(

'package_id'=>$package_id,

'package_group_id'=>$groups[$i]

);

$this->Record->insert("package_group", $vars);

}

}

}

Posted

Here, I've fixed it:

 

Starting at line 305 in package model. However this is not ideal, as it won't retain ordering if a group is added (even if old groups are kept)
 
What should be done is - empty the group/package relationship table (excluding the ids of groups in the array from the submitted form), then do an array diff on the group ids, and add the new groups. that way the old relationship records are kept instead of blanked every time. since the ordering appears to be in the table for the many to many relationship between groups and packages.
 
I'll try to implement when I have some time but keep in mind I have been working with the internal code for all of 2 days now so I am not very familiar.
 
$group_ids = array();
foreach ($package->groups as $group) {
$group_ids[] = $group->id;
}
 
// Replace all group assignments with those that are given (if any given)
if (isset($vars['groups']) && $vars['groups'] != $group_ids)
$this->setGroups($package_id, $vars['groups']);
  • 2 weeks later...
Guest
This topic is now closed to further replies.
×
×
  • Create New...