if (isset($params['error'])) { $smarty->assign('error', $params['error']); } // calculate the union (yep, union, not intersection) // of all of the properties of all of the member groups // preferring all items with a priority of 2 $properties = array(); $groups = 0; foreach ($params as $key => $val) { if (preg_match('/^memberof_/', $key)) { $groups++; // get the groupid from the checkbox $grpid = substr($key, strlen('memberof_')); // have the group id, now get a list of the properties $proprelations = $this->GetGroupPropertyRelations($grpid); $properties = RRUtils::array_merge_by_name_required($properties, $proprelations); uasort($properties, array('cge_array', 'compare_elements_by_sortorder_key')); } } if ($groups == 0) { if ($this->GetPreference('require_onegroup') == 1) { $params['error'] = 1; $params['message'] = $this->Lang('error_onegrouprequired'); $this->myRedirect($id, 'adduser', $returnid, $params, true); return; } if (isset($params['user_id'])) { $this->myRedirect($id, 'do_edituser3', $returnid, $params, true); } else { $this->myRedirect($id, 'do_adduser3', $returnid, $params, true); }
if (isset($params['cancel'])) { $this->RedirectToTab($id, 'users'); } $user_id = (int) $params['user_id']; // get field definitions. $defns = $this->GetPropertyDefns(); // get the property relations for the selected group(s). $parms1 = cge_array::explode_with_key($params['step1_params']); $groupprops = array(); $groupids = array(); foreach ($parms1 as $key => $value) { if (startswith($key, 'memberof_')) { $gid = (int) substr($key, strlen('memberof_')); $groupids[] = $gid; $relns = $this->GetGroupPropertyRelations($gid); $groupprops = RRUtils::array_merge_by_name_required($groupprops, $relns); uasort($groupprops, array('cge_array', 'compare_elements_by_sortorder_key')); } } $groupprops = cge_array::to_hash($groupprops, 'name'); // get the field info $fieldlist = array(); foreach ($params as $k => $v) { if (preg_match('/^hidden_/', $k)) { $fldname = substr($k, strlen('hidden_')); $fieldlist[$fldname] = $v; } } // now merge form values for each of the fields foreach ($groupprops as $fldname => $reln) { $v = '';
$this->_DisplayErrorPage($id, $params, $returnid, $result[1]); return; } $smarty->assign('userinfo', $userinfo[1]); $smarty->assign('email_address', $this->GetEmail($uid)); $groups = $this->GetMemberGroupsArray($uid); if (!$groups) { // This user isn't a member of any groups return; } // now we have the groups, we build a union of all of the groups properties $prop2 = array(); foreach ($groups as $grprecord) { $gid = $grprecord['groupid']; $proprelations = $this->GetGroupPropertyRelations($gid); $prop2 = RRUtils::array_merge_by_name_required($prop2, $proprelations); uasort($prop2, array('cge_array', 'compare_elements_by_sortorder_key')); } // now we merge in all of the property definitions $defns = $this->GetPropertyDefns(); $prop3 = array(); foreach ($prop2 as $oneprop) { foreach ($defns as $onedefn) { if ($onedefn['name'] == $oneprop['name']) { $oneprop['prompt'] = $onedefn['prompt']; $oneprop['type'] = $onedefn['type']; break; } } $prop3[] = $oneprop; }
function GetUserPropertyRelations($uid) { $groups = $this->GetMemberGroupsArray($uid); if (!is_array($groups) || count($groups) == 0) { return; } $uprops = array(); for ($a = 0; $a < count($groups); $a++) { $gid = $groups[$a]['groupid']; $relns = $this->GetGroupPropertyRelations($gid); $uprops = RRUtils::array_merge_by_name_required($uprops, $relns); usort($uprops, array('cge_array', 'compare_elements_by_sortorder_key')); } return $uprops; }