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 _show_grup()
{
    isUserLoggedIn();
    $grupa = new Grupa(getdbh());
    $allGroups = $grupa->fetchAll();
    $result['grupa'] = $allGroups;
    $data['msg'][] = View::do_fetch(VIEW_PATH . 'afisare_grupa.tpl.php', $result);
    View::do_dump(VIEW_PATH . 'layout.php', $data);
}
function _addTemaView()
{
    isUserLoggedIn();
    if (getUserType() == 'profesor') {
        $grupa = new Grupa(getdbh());
        $result['grupa'] = $grupa->fetchAll();
        $data['msg'][] = View::do_fetch(VIEW_PATH . 'addTema.tpl.php', $result);
        View::do_dump(VIEW_PATH . 'layout.php', $data);
    }
}
function _showGrupaDetails($id = 0, $numeGrupa = '')
{
    isUserLoggedIn();
    $grupa = new Grupa(getdbh());
    $result['users'] = $grupa->fetchGrupaUsers($id);
    $result['nume'] = $numeGrupa;
    $result['id'] = $id;
    $data['msg'][] = View::do_fetch(VIEW_PATH . 'showGrupaDetails.tpl.php', $result);
    View::do_dump(VIEW_PATH . 'layout.php', $data);
}
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 _showTeme()
{
    isUserLoggedIn();
    if (getUserType() == 'admin' || getUserType() == 'profesor') {
        $data['msg'][] = View::do_fetch(VIEW_PATH . 'afisareTemeProfesor.tpl.php');
        View::do_dump(VIEW_PATH . 'layout.php', $data);
    } else {
        $grupaMea = new Grupa(getdbh());
        $result = $grupaMea->getGrupaUserCurent(getUserID());
        $idGrupaMea = (int) $result[0]['ID_GRUPA'];
        $tema = new Teme(getdbh());
        $result['tema'] = $tema->getTemeStudentCurent($idGrupaMea);
        $data['msg'][] = View::do_fetch(VIEW_PATH . 'afisareTemeStudent.tpl.php', $result);
        View::do_dump(VIEW_PATH . 'layout.php', $data);
    }
}
function _suportCurs()
{
    isUserLoggedIn();
    if (getUserType() == 'student') {
        $data['msg'][] = View::do_fetch(VIEW_PATH . 'suport_curs_stud.php');
        View::do_dump(VIEW_PATH . 'layout.php', $data);
    } else {
        $grupa = new Grupa(getdbh());
        $getGroups = $grupa->fetchAll();
        $result['grupa'] = $getGroups;
        $materie = new Materii(getdbh());
        $getMaterii = $materie->fetchGroupaAndMateria();
        $result['materie'] = $getMaterii;
        $data['msg'][] = View::do_fetch(VIEW_PATH . 'suport_curs_prof.php', $result);
        View::do_dump(VIEW_PATH . 'layout.php', $data);
    }
}
function _updateGrupa()
{
    isUserLoggedIn();
    $grupa = new Grupa(getdbh());
    if (isset($_POST['sef_grupa'])) {
        $result = $grupa->updateGrupa($_POST['idGrupa'], $_POST['nume'], $_POST['an'], $_POST['profil'], $_POST['sef_grupa']);
    } else {
        $result = $grupa->updateGrupa($_POST['idGrupa'], $_POST['nume'], $_POST['an'], $_POST['profil']);
    }
    if ($result) {
        $data['msg'][] = 'Grupa a fost modificata cu success';
        $data['redirect'][] = 'administrare/show_grup';
        View::do_dump(VIEW_PATH . 'layout.php', $data);
    } else {
        $data['msg'][] = "Eroare la modificarea grupei";
        $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);
    }
}
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;
    }
}
Example #12
0
 public function actionGrupaFields()
 {
     $result = Proc::GenerateColModel(Grupa::model());
     echo json_encode($result);
 }
Example #13
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      Grupa $value A Grupa object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(Grupa $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
Example #14
0
 /**
  * Declares an association between this object and a Grupa object.
  *
  * @param      Grupa $v
  * @return     KlientGrupa The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setGrupa(Grupa $v = null)
 {
     if ($v === null) {
         $this->setGrupaId(NULL);
     } else {
         $this->setGrupaId($v->getId());
     }
     $this->aGrupa = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Grupa object, it will not be re-added.
     if ($v !== null) {
         $v->addKlientGrupa($this);
     }
     return $this;
 }