function _addGrupaMember() { isUserLoggedIn(); $grupa = new Grupa(getdbh()); $checkGroup = $grupa->checkGroupRegistration($_POST['userID']); if ($checkGroup != false) { if ($checkGroup['ID_GRUPA'] != $_POST['grupaID']) { $delete = $grupa->deleteGrupaMember($checkGroup['ID']); } } $check = $grupa->checkRegister($_POST['grupaID'], $_POST['userID']); if ($check == false) { $addMember = $grupa->addGrupaMember($_POST['grupaID'], $_POST['userID']); if ($addMember) { $data['msg'][] = "Studentul a fost inscris in grupa"; $data['redirect'][] = 'administrare/show_grup'; View::do_dump(VIEW_PATH . 'layout.php', $data); } else { $data['msg'][] = "Eroare la inscriere"; $data['redirect'][] = 'administrare/show_grup'; View::do_dump(VIEW_PATH . 'layout.php', $data); } } else { $data['msg'][] = "Studentul este inscris la aceasta grupa"; $data['redirect'][] = 'administrare/show_grup'; View::do_dump(VIEW_PATH . 'layout.php', $data); } }
function _updateUser() { isUserLoggedIn(); $user = new User(getdbh()); $grupa = new Grupa(getdbh()); if ($_POST['currentGroup'] > 0 && $_POST['currentGroup'] != $_POST['grupa']) { $remove = $grupa->removeGroupMember($_POST['currentGroup'], $_POST['idUser']); } $check = $grupa->checkRegister($_POST['grupa'], $_POST['idUser']); if ($check == false) { $addGrupa = $grupa->addGrupaMember($_POST['grupa'], $_POST['idUser']); } $result = $user->updateUser($_POST['idUser'], $_POST['email'], $_POST['nume'], $_POST['prenume'], $_POST['type'], $_POST['status']); if ($result) { $data['msg'][] = 'Userul a fost modificat cu success'; $data['redirect'][] = 'administrare/show_users'; View::do_dump(VIEW_PATH . 'layout.php', $data); } else { $data['msg'][] = "Eroare la modificarea userului"; $data['redirect'][] = 'administrare/show_users'; View::do_dump(VIEW_PATH . 'layout.php', $data); } }