function _deleteGrupaMember() { isUserLoggedIn(); switch ($_POST['actiune']) { case 'delete': reset($_POST); $key = key($_POST); $grupaId = explode("_", $key); $grupa = new Grupa(getDbh()); $deleteMember = $grupa->deleteGrupaMember($grupaId[1]); if ($deleteMember) { $data['msg'][] = "Studentul a fost scos din grupa"; $data['redirect'][] = 'administrare/show_grup'; View::do_dump(VIEW_PATH . 'layout.php', $data); } else { $data['msg'][] = "Eroare la stergerea din grupa"; $data['redirect'][] = 'administrare/show_grup'; View::do_dump(VIEW_PATH . 'layout.php', $data); } break; case 'delete_all': $sterse = 0; $nesterse = 0; $grupa = new Grupa(getDbh()); foreach ($_POST as $key) { if ($key == 'delete_all' || $key == 'Sterge tot') { continue; } else { $grupaID = explode("_", $key); $deleteMember = $grupa->deleteGrupaMember($grupaID[1]); if ($deleteMember) { $sterse++; } else { $nesterse++; } } } if ($sterse > 0) { $data['msg'][] = $sterse . " studenti au fost stersi cu success"; $data['redirect'][] = 'administrare/show_grup'; View::do_dump(VIEW_PATH . 'layout.php', $data); } else { $data['msg'][] = $nesterse . " studenti nu au fost stersi"; $data['redirect'][] = 'administrare/show_grup'; View::do_dump(VIEW_PATH . 'layout.php', $data); } break; } }
function _adaugareUser() { isUserLoggedIn(); $user = new User(getDbh()); $result = $user->addUserByProf($_POST['nume'], $_POST['prenume']); if ($result) { $data['msg'][] = 'Studentul a fost adaugat cu success'; $data['redirect'][] = 'administrare/show_users'; View::do_dump(VIEW_PATH . 'layout.php', $data); } else { $data['msg'][] = "Eroare la adaugarea studentului"; $data['redirect'][] = 'administrare/show_users'; View::do_dump(VIEW_PATH . 'layout.php', $data); } }
function _adminTeme() { isUserLoggedIn(); switch ($_POST['actiune']) { case 'add': $tema = new Teme(getDbh()); $materii = new Materii(getdbh()); // $fetch = $materii->getMateriiDetails($_POST['grupaID']); $fetch = $materii->getMateriiDetails(1); if ($_FILES['fileToUpload']['name'] != '') { if ($_FILES['fileToUpload']['size'] > 5242880) { redirect('teme1'); } $file = $_FILES['fileToUpload']['tmp_name']; $new_file_name = strtolower($_FILES['fileToUpload']['name']); $FileType = pathinfo($new_file_name, PATHINFO_EXTENSION); if ($FileType != "xml" && $FileType != "png" && $FileType != "bmp" && $FileType != "jpg" && $FileType != "gif" && $FileType != "doc" && $FileType != "docx" && $FileType != "pdf") { echo "Sorry, only JPG, PNG, GIF, DOC, DOCX, BMP, PDF, XML files are allowed."; redirect('teme2'); } } if ($_FILES['fileToUpload']['name'] != '') { $result = $tema->addTema($fetch['ID_USER'], $_POST['grupaID'], $_POST['materie'], $_POST['denumire'], $_POST['detalii'], $file); } else { $result = $tema->addTema($fetch['ID_USER'], $_POST['grupaID'], $_POST['materie'], $_POST['denumire'], $_POST['detalii']); } if ($result) { $data['msg'][] = "Tema de licenta a fost adaugata cu success"; $data['redirect'][] = 'teme'; View::do_dump(VIEW_PATH . 'layout.php', $data); } else { $data['msg'][] = "Eroare la adaugare"; $data['redirect'][] = 'teme'; View::do_dump(VIEW_PATH . 'layout.php', $data); } break; case 'edit': case 'delete': break; default: //echo "wrong action" break; } }
function _adminGrupa() { isUserLoggedIn(); //$_POST['checkbox'] = "id_1"- inseamna ca in interfata s-a selectat checkbox pt user_id 1 switch ($_POST['actiune']) { case 'edit': reset($_POST); $key = key($_POST); $grupa_id = explode("_", $key); $grupa = new Grupa(getDbh()); $grupa_details = $grupa->getGrupaDetails($grupa_id[1]); $grupa_users = $grupa->fetchGrupaUsers($grupa_id[1]); $result['grupa'] = $grupa_details; $result['studenti'] = $grupa_users; $data['msg'][] = View::do_fetch(VIEW_PATH . 'modifica_grupa.tpl.php', $result); View::do_dump(VIEW_PATH . 'layout.php', $data); break; case 'delete_all': $sterse = 0; $nesterse = 0; $grupa = new Grupa(getDbh()); foreach ($_POST as $key) { if ($key == 'delete_all' || $key == 'Sterge tot') { continue; } else { $grupa_id = explode("_", $key); if ($grupa->deleteGrupa($grupa_id[1]) == true) { $sterse++; } else { $nesterse++; } } } if ($sterse > 0) { $data['msg'][] = $sterse . " au fost sterse cu success"; $data['redirect'][] = 'administrare/show_grup'; View::do_dump(VIEW_PATH . 'layout.php', $data); } else { $data['msg'][] = $nesterse . "nu au fost sterse"; $data['redirect'][] = 'administrare/show_grup'; View::do_dump(VIEW_PATH . 'layout.php', $data); } break; case 'delete': reset($_POST); $key = key($_POST); $grupa_id = explode("_", $key); $grupa = new Grupa(getDbh()); if ($grupa->deleteGrupa($grupa_id[1]) == true) { $data['msg'][] = " Grupa a fost stersa cu success"; $data['redirect'][] = 'administrare/show_grup'; View::do_dump(VIEW_PATH . 'layout.php', $data); } else { $data['msg'][] = " Grupa nu a fost stersa"; $data['redirect'][] = 'administrare/show_grup'; View::do_dump(VIEW_PATH . 'layout.php', $data); } break; case 'add': $grupa = new Grupa(getDbh()); $result = $grupa->addGrupa($_POST['nume'], $_POST['an'], $_POST['profil']); if ($result) { $data['msg'][] = 'Grupa a fost adaugata cu success'; $data['redirect'][] = 'administrare/addGrupa'; View::do_dump(VIEW_PATH . 'layout.php', $data); } else { $data['msg'][] = "Eroare la adaugarea grupei"; $data['redirect'][] = 'administrare/addGrupa'; View::do_dump(VIEW_PATH . 'layout.php', $data); } break; default: //echo "wrong action" break; } }
function _adminUsers() { isUserLoggedIn(); switch ($_POST['actiune']) { case 'edit': reset($_POST); $key = key($_POST); $user_id = explode("_", $key); $user = new User(getDbh()); $user_details = $user->getUserDetails($user_id[1]); $grupa = new Grupa(getdbh()); $groupsDetails = $grupa->fetchAll(); $result['grupa'] = $groupsDetails; $result['user'] = $user_details; $result['ID'] = $user_id[1]; $data['msg'][] = View::do_fetch(VIEW_PATH . 'modifica_user.tpl.php', $result); View::do_dump(VIEW_PATH . 'layout.php', $data); break; case 'delete': reset($_POST); $key = key($_POST); $user_id = explode("_", $key); $user = new User(getDbh()); if ($user->deleteUser($user_id[1]) == true) { $data['msg'][] = " Userul a fost sters cu success"; $data['redirect'][] = 'administrare/show_users'; View::do_dump(VIEW_PATH . 'layout.php', $data); } else { $data['msg'][] = " Userul nu a fost sters"; $data['redirect'][] = 'administrare/show_users'; View::do_dump(VIEW_PATH . 'layout.php', $data); } break; case 'delete_all': $sterse = 0; $nesterse = 0; $user = new User(getDbh()); foreach ($_POST as $key) { if ($key == 'delete_all') { continue; } else { $user_id = explode("_", $key); if ($user->deleteUser($user_id[1]) == true) { $sterse++; } else { $nesterse++; } } } if ($sterse > 0) { $data['msg'][] = $sterse . "useri au fost stersi cu success"; $data['redirect'][] = 'administrare/show_users'; View::do_dump(VIEW_PATH . 'layout.php', $data); } else { $data['msg'][] = $nesterse . "useri nu au fost stersi"; $data['redirect'][] = 'administrare/show_users'; View::do_dump(VIEW_PATH . 'layout.php', $data); } break; default: //echo "wrong action" break; } }