Ejemplo n.º 1
0
 public function getList($order = "didascalia")
 {
     $order = trim(filter_var($order, FILTER_SANITIZE_STRING));
     //interrogazione tabella
     $sql = "SELECT * FROM upload ORDER BY {$order}";
     $auth = $this->connector->query($sql);
     $list = array();
     // controllo sul risultato dell'interrogazione
     if (mysql_num_rows($auth) > 0) {
         $doc = new Document();
         $doc->setConnector($this->connector);
         $course = new Course();
         $course->setConnector($this->connector);
         while ($res = $this->connector->getObjectResult($auth)) {
             $doc = new Document($res->id, $res->path, $res->tipo, $res->didascalia);
             //Calcolo le informazioni di servizio
             if ($res->tipo == 1) {
                 $doc->course_name = "TUTTI";
             } else {
                 $doc->course_name = $course->getById($res->tipo)->name;
             }
             $list[] = $doc;
         }
     }
     return $list;
 }
Ejemplo n.º 2
0
 public function getById($id)
 {
     $id = (int) $id;
     $sql = "SELECT * FROM piani WHERE id_piano='{$id}' LIMIT 1";
     $auth = $this->connector->query($sql);
     if (mysql_num_rows($auth) > 0) {
         //Inializzo le classi di servizio
         $course = new Course();
         $course->setConnector($this->connector);
         $subjectPlan = new SubjectPlan();
         $subjectPlan->setConnector($this->connector);
         $res = $this->connector->getObjectResult($auth);
         //Recupero la lista delle entries
         $sub_list = $subjectPlan->getList($res->id_piano, "anno");
         $plan = new Plan($res->id_piano, $res->codice, $res->id_corso, $sub_list);
         //Calcolo le informazioni di servizio
         $plan->course_name = $course->getById($plan->course_id)->name;
         //ritorno il piano cercato
         return $plan;
     }
     return false;
 }
Ejemplo n.º 3
0
 public function getById($id)
 {
     // interrogazione della tabella
     $sql = "SELECT * FROM studenti WHERE id_studente='{$id}'";
     $auth = $this->connector->query($sql);
     $student = null;
     if (mysql_num_rows($auth) > 0) {
         $res = $this->connector->getObjectResult($auth);
         $student = new Student(get_object_vars($res));
     }
     //Gestisco i dati di servizio
     $plan = new Plan();
     $plan->setConnector($this->connector);
     $student_plan = $plan->getById($student->id_plan);
     $student->course_id = $student_plan->course_id;
     $course = new Course();
     $course->setConnector($this->connector);
     $student_course = $course->getById($student->course_id);
     $student->course_name = $student_course->name;
     $student->course_year = $student_course->years;
     return $student;
 }
Ejemplo n.º 4
0
function showCourse()
{
    global $connector;
    $page = "course.php";
    $course = new Course();
    $course->setConnector($connector);
    if ($_POST['operation']) {
        list($operation, $params) = explode("#", $_POST['operation']);
        switch ($operation) {
            case 'saveChanges':
                $course->storeFormValues($_POST);
                $error_msg = $course->insert();
                if ($error_msg) {
                    $result['edit'] = $course;
                }
                break;
            case 'delete':
                $error_msg = $course->delete($params);
                break;
            case 'edit':
                $result['edit'] = $course->getById($params);
                break;
            case 'editChanges':
                $course->storeFormValues($_POST);
                $error_msg = $course->update();
                break;
            default:
                $error_msg = "Operazione non valida";
        }
        if ($error_msg != "") {
            $result["errorMessage"] = $error_msg;
        } elseif ($operation != 'edit') {
            $result["statusMessage"] = "Operazione completata!";
        }
    }
    if (isset($_POST['search'])) {
        $result["courses"] = $course->search($_POST['search']);
    } else {
        $result["courses"] = $course->getList();
    }
    $page = "course.php";
    include_once BASE_PATH . "template.php";
}