if ($form->isSubmitted() && $form->validate()) { try { $values = $form->exportValues(); $fields['name'] = $values['name']; $fields['description'] = $values['description']; $fields['user_types_ID'] = $values['user_types_ID']; $fields['unique_key'] = $values['unique_key']; $fields['is_default'] = $values['is_default']; $fields['self_enroll'] = $values['self_enroll']; $fields['key_max_usage'] = $values['key_max_usage'] ? $values['key_max_usage'] : 0; if (isset($_GET['edit_user_group'])) { $values['key_max_usage'] or $fields['key_current_usage'] = 0; $currentGroup->group = array_merge($currentGroup->group, $fields); $currentGroup->persist(); } else { $currentGroup = EfrontGroup::create($fields); } eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=user_groups&edit_user_group=" . $currentGroup->group['id'] . "&message=" . urlencode(_OPERATIONCOMPLETEDSUCCESSFULLY) . "&message_type=success"); } catch (Exception $e) { handleNormalFlowExceptions($e); } } } $smarty->assign('T_USERGROUPS_FORM', $form->toArray()); if (isset($_GET['edit_user_group'])) { try { if (isset($_GET['ajax']) && $_GET['ajax'] == "usersTable") { $roles = EfrontUser::getRoles(true); $smarty->assign("T_ROLES", $roles); $constraints = array('archive' => false, 'return_objects' => false) + createConstraintsFromSortedTable(); $users = $currentGroup->getGroupUsersIncludingUnassigned($constraints);
$smarty->assign("T_USER_TRAFFIC", $traffic); $actions = array('login' => _LOGIN, 'logout' => _LOGOUT, 'lesson' => _ACCESSEDLESSON, 'content' => _ACCESSEDCONTENT, 'tests' => _ACCESSEDTEST, 'test_begin' => _BEGUNTEST, 'lastmove' => _NAVIGATEDSYSTEM); $smarty->assign("T_ACTIONS", $actions); $smarty->display($_SESSION['s_type'] . '.tpl'); } else { if (isset($_GET['add_to_existing_group'])) { try { $group = new EfrontGroup($_GET['add_to_existing_group']); $group->addUsers($recipients_array); } catch (Exception $e) { echo $e->getMessage(); } } else { if (isset($_GET['add_to_new_group'])) { try { $group = EfrontGroup::create(array("name" => $_GET['add_to_new_group'])); $group->addUsers($recipients_array); echo $group->group['id']; } catch (Exception $e) { echo $e->getMessage(); } } else { if (isset($_GET['add_course'])) { try { $course = new EfrontCourse($_GET['add_course']); $course->addUsers($recipients_array); } catch (Exception $e) { header("HTTP/1.0 500"); echo $e->getMessage() . ' (' . $e->getCode() . ')'; } }