/**
  * function instance
  *
  * @param string $dsn - a valid data source name
  * @return MessageHandler instance
  */
 public static function instance($dsn = NULL)
 {
     if (self::$instance == NULL) {
         self::$instance = new MessageHandler($dsn);
     } else {
         self::$instance->setDSN($dsn);
     }
     return self::$instance;
 }
 public function delete()
 {
     if (ProjectService::delete(Request::get('id'))) {
         MessageHandler::instance()->addMessage('Deleted project');
         $this->asJson(true);
     } else {
         MessageHandler::instance()->addError('Could not delete project');
         $this->asJson(false);
     }
 }
 public function register()
 {
     $this->validate(array('name' => 'required,min(2)', 'email' => 'required,email', 'password' => 'required,min(4)', 'password2' => 'required,min(4),equal(password)'));
     $userDoc = Request::post()->get('name', 'email', 'password');
     $userDoc->password = md5($userDoc->password);
     $userDoc = UserService::save($userDoc);
     if (!$userDoc) {
         MessageHandler::instance()->addError('E-mail was already registered - forgot your password?');
         return;
     }
     $user = new UserModel($userDoc);
     SessionHandler::instance()->setUser($user);
     MessageHandler::instance()->addMessage('You were successfully registered and logged in');
     $this->redirect();
 }
Exemple #4
0
/*
 * YOUR CODE HERE
 */
include_once 'include/StringValidation.inc.php';
include_once 'include/address_book.inc.php';
if (!isset($op)) {
    $op = 'default';
}
$success = HTTP_ROOT_DIR . '/comunica/list_events.php';
$error_page = HTTP_ROOT_DIR . '/comunica/send_event.php';
$title = translateFN('Pubblica appuntamento');
//$rubrica_ok = 0; // Address book not loaded yet
// Has the form been posted?
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if (isset($spedisci)) {
        $mh = MessageHandler::instance(MultiPort::getDSN($sess_selected_tester));
        // Initialize errors array
        $errors = array();
        // Trim all submitted data
        $form = $_POST;
        while (list($key, $value) = each($form)) {
            ${$key} = $value;
        }
        if (!isset($destinatari) || DataValidator::validate_not_empty_string($destinatari) === FALSE) {
            $errors['destinatari'] = ADA_EVENT_PROPOSAL_ERROR_RECIPIENT;
        }
        if (!isset($titolo) || DataValidator::validate_not_empty_string($titolo) === FALSE) {
            $errors['titolo'] = ADA_EVENT_PROPOSAL_ERROR_SUBJECT;
        }
        if (($value = ADAEventProposal::canProposeThisDateTime($userObj, $data_evento, $ora_evento, $sess_selected_tester)) !== TRUE) {
            $errors['$data_evento'] = $value;
Exemple #5
0
  * Obtain a messagehandler instance for the correct tester
  */
 if (MultiPort::isUserBrowsingThePublicTester()) {
     /*
      * In base a event_msg_id, ottenere connessione al tester appropriato
      */
     $data_Ar = MultiPort::geTesterAndMessageId($msg_id);
     $tester = $data_Ar['tester'];
 } else {
     /*
      * We are inside a tester
      */
     $tester = $sess_selected_tester;
 }
 $tester_dsn = MultiPort::getDSN($tester);
 $mh = MessageHandler::instance($tester_dsn);
 if ($selected_date == 0) {
     /*
      * Nessuna tra le date proposte va bene
      */
     $flags = ADA_EVENT_PROPOSAL_NOT_OK | $practitioner_proposal['flags'];
     $message_content = $practitioner_proposal['testo'];
     $message_ha = array('tipo' => ADA_MSG_AGENDA, 'flags' => $flags, 'mittente' => $mittente, 'destinatari' => $destinatari, 'data_ora' => 'now', 'titolo' => $subject, 'testo' => $message_content);
     /*
      * This email message is sent only to the practitioner.
      * Send here.
      */
     $clean_subject = ADAEventProposal::removeEventToken($subject);
     $email_message_ha = array('tipo' => ADA_MSG_MAIL, 'mittente' => $adm_uname, 'destinatari' => $destinatari, 'data_ora' => 'now', 'titolo' => 'ADA: ' . translateFN('a user asks for new event proposal dates'), 'testo' => sprintf(translateFN('Dear practitioner, the user %s is asking you for new event dates for the appointment %s.\\r\\nThank you.'), $userObj->getFullName(), $clean_subject));
     /*
      * Send the email message
Exemple #6
0
     }
 } else {
     $switcher_uname = "";
     // probably was a public service or an error
 }
 // 3. send a message to the user (a mail, an SMS, ...)
 $titolo = 'ADA: ' . translateFN('richiesta di servizio');
 $testo = translateFN("Un utente con dati: ");
 $testo .= $name . " " . $surname;
 $testo .= translateFN(" ha richiesto  il servizio: ");
 $testo .= $service_name . ".";
 $testo .= translateFN(" Riceverai un messaggio contenente le proposte di appuntamento. ");
 // $mh = MessageHandler::instance(MultiPort::getDSN($tester));
 // using the previous  MH if exists
 //if (!isset($mh))
 $mh = MessageHandler::instance(MultiPort::getDSN($tester));
 // prepare message to send
 $destinatari = array($username);
 $message3_ha = array();
 $message3_ha['titolo'] = $titolo;
 $message3_ha['testo'] = $testo;
 $message3_ha['destinatari'] = $destinatari;
 $message3_ha['data_ora'] = "now";
 $message3_ha['tipo'] = ADA_MSG_MAIL;
 $message3_ha['mittente'] = $adm_uname;
 // delegate sending to the message handler
 $res3 = $mh->send_message($message3_ha);
 if (AMA_DataHandler::isError($res3)) {
     // $errObj = new ADA_Error($res,translateFN('Impossibile spedire il messaggio'),
     //NULL,NULL,NULL,$error_page.'?err_msg='.urlencode(translateFN('Impossibile spedire il messaggio')));
 }
 function get_class_reportFN($id_course, $order = "", $index_att = "", $type = 'HTML')
 {
     $dh = $GLOBALS['dh'];
     $http_root_dir = $GLOBALS['http_root_dir'];
     $debug = isset($GLOBALS['debug']) ? $GLOBALS['debug'] : null;
     $npar = isset($GLOBALS['npar']) ? $GLOBALS['npar'] : null;
     $hpar = isset($GLOBALS['hpar']) ? $GLOBALS['hpar'] : null;
     $mpar = isset($GLOBALS['mpar']) ? $GLOBALS['mpar'] : null;
     $epar = isset($GLOBALS['epar']) ? $GLOBALS['epar'] : null;
     $bpar = isset($GLOBALS['mpar']) ? $GLOBALS['mpar'] : null;
     $cpar = isset($GLOBALS['epar']) ? $GLOBALS['epar'] : null;
     // default parameters for activity index are in configuration file
     if (empty($npar)) {
         $npar = NOTE_PAR;
     }
     // notes
     if (!isset($hpar)) {
         $hpar = HIST_PAR;
     }
     // history
     if (!isset($mpar)) {
         $mpar = MSG_PAR;
     }
     //messages
     if (!isset($epar)) {
         $epar = EXE_PAR;
     }
     // exercises
     if (!isset($bpar)) {
         $bpar = defined('BKM_PAR') ? BKM_PAR : null;
     }
     //bookmarks
     if (!isset($cpar)) {
         $cpar = defined('CHA_PAR') ? CHA_PAR : null;
     }
     // chat
     $student_list_ar = $this->student_list;
     $id_instance = $this->id;
     if ($student_list_ar != 0) {
         $info_course = $dh->get_course($id_course);
         // Get title course
         if (AMA_DataHandler::isError($info_course)) {
             $msg = $info_course->getMessage();
             return $msg;
         }
         $course_title = $info_course['titolo'];
         $instance_course_ha = $dh->course_instance_get($id_instance);
         // Get the instance courses data
         if (AMA_DataHandler::isError($instance_course_ha)) {
             $msg = $instance_course_ha->getMessage();
             return $msg;
         }
         $start_date = AMA_DataHandler::ts_to_date($instance_course_ha['data_inizio'], ADA_DATE_FORMAT);
         $num_student = -1;
         $tot_history_count = 0;
         $tot_exercises_score = 0;
         $tot_exercises_number = 0;
         $tot_added_notes = 0;
         $tot_read_notes = 0;
         $tot_message_count = 0;
         $tot_message_count_in = 0;
         $tot_message_count_out = 0;
         $tot_bookmarks_count = 0;
         $tot_chatlines_count_out = 0;
         $tot_index = 0;
         $tot_level = 0;
         /**
          * @author giorgio 27/ott/2014
          * 
          * change to:
          * $report_generation_TS = time();
          * 
          * to have full date & time generation of report
          * but be warned that table log_classi may grow A LOT!
          */
         $report_generation_TS = dt2tsFN(today_dateFN());
         if (MODULES_TEST) {
             $tot_exercises_score_test = 0;
             $tot_exercises_number_test = 0;
             $tot_exercises_score_survey = 0;
             $tot_exercises_number_survey = 0;
             $test_db = AMATestDataHandler::instance(MultiPort::getDSN($_SESSION['sess_selected_tester']));
             $test_score = $test_db->getStudentsScores($id_course, $id_instance);
         }
         foreach ($student_list_ar as $one_student) {
             $num_student++;
             //starts with 0
             $id_student = $one_student['id_utente_studente'];
             $student_level = $one_student['livello'];
             $status_student = $one_student['status'];
             $dati['id'] = $id_student;
             $dati['level'] = $student_level;
             $ymdhms = today_dateFN();
             $utime = dt2tsFN($ymdhms);
             $dati['date'] = $report_generation_TS;
             if (!empty($id_student) and ($status_student == ADA_STATUS_SUBSCRIBED or $status_student == ADA_SERVICE_SUBSCRIPTION_STATUS_COMPLETED)) {
                 $studentObj = MultiPort::findUser($id_student);
                 //new Student($id_student,$id_instance);
                 if ($studentObj->full != 0) {
                     //==0) {
                     $err_msg = $studentObj->error_msg;
                 } else {
                     if ($studentObj instanceof ADAPractitioner) {
                         /**
                          * @author giorgio 14/apr/2015
                          * 
                          * If student is actually a tutor, build a new student
                          * object for history and evaluation purposes
                          */
                         $studentObj = $studentObj->toStudent();
                     }
                     $student_name = $studentObj->getFullname();
                     //$studentObj->nome." ".$studentObj->cognome;
                     // vito
                     $studentObj->set_course_instance_for_history($id_instance);
                     //$studentObj->history->setCourseInstance($id_instance);
                     $studentObj->history->setCourse($id_course);
                     $studentObj->get_exercise_dataFN($id_instance, $id_student);
                     $st_exercise_dataAr = $studentObj->user_ex_historyAr;
                     $st_score = 0;
                     $st_exer_number = 0;
                     if (is_array($st_exercise_dataAr)) {
                         foreach ($st_exercise_dataAr as $exercise) {
                             $st_score += $exercise[7];
                             $st_exer_number++;
                         }
                     }
                     $dati['exercises'] = $st_exer_number;
                     $dati['score'] = $st_score;
                     if (MODULES_TEST) {
                         $st_score_test = isset($test_score[$id_student]['score_test']) ? $test_score[$id_student]['score_test'] : 0;
                         $st_exer_number_test = isset($test_score[$id_student]['max_score_test']) ? $test_score[$id_student]['max_score_test'] : 0;
                         $dati['exercises_test'] = $st_exer_number_test;
                         $dati['score_test'] = $st_score_test;
                         $st_score_survey = isset($test_score[$id_student]['score_survey']) ? $test_score[$id_student]['score_survey'] : 0;
                         $st_exer_number_survey = isset($test_score[$id_student]['max_score_survey']) ? $test_score[$id_student]['max_score_survey'] : 0;
                         $dati['exercises_survey'] = $st_exer_number_survey;
                         $dati['score_survey'] = $st_score_survey;
                     }
                     $sub_courses = $dh->get_subscription($id_student, $id_instance);
                     if ($sub_courses['tipo'] == ADA_STATUS_SUBSCRIBED) {
                         $out_fields_ar = array('nome', 'titolo', 'id_istanza', 'data_creazione');
                         $clause = "tipo = '" . ADA_NOTE_TYPE . "' AND id_utente = '{$id_student}'";
                         $nodes = $dh->find_course_nodes_list($out_fields_ar, $clause, $id_course);
                         $added_nodes_count = count($nodes);
                         $added_nodes_count_norm = str_pad($added_nodes_count, 5, "0", STR_PAD_LEFT);
                         $added_notes = "<!-- {$added_nodes_count_norm} --><a href={$http_root_dir}/tutor/tutor.php?op=student_notes&id_instance={$id_instance}&id_student={$id_student}>" . $added_nodes_count . "</a>";
                         //$added_notes = $added_nodes_count;
                     } else {
                         $added_notes = "<!-- 0 -->-";
                     }
                     $read_notes_count = $studentObj->total_visited_notesFN($id_student, $id_course);
                     if ($read_notes_count > 0) {
                         $read_nodes_count_norm = str_pad($read_notes_count, 5, "0", STR_PAD_LEFT);
                         $read_notes = "<!-- {$read_nodes_count_norm} -->{$read_notes_count}";
                     } else {
                         $read_notes = "<!-- 0 -->-";
                     }
                     $st_history_count = "0";
                     $debug = 0;
                     $st_history_count = $studentObj->total_visited_nodesFN($id_student, ADA_LEAF_TYPE);
                     // vito, 11 mar 2009. Ottiene solo il numero di visite a nodi di tipo foglia.
                     // vogliamo anche il numero di visite a nodi di tipo gruppo.
                     $st_history_count += $studentObj->total_visited_nodesFN($id_student, ADA_GROUP_TYPE);
                     $dati['visits'] = $st_history_count;
                     $st_name = "<!-- {$student_name} --><a href=" . $http_root_dir . "/tutor/tutor.php?op=zoom_student&id_student=" . $id_student;
                     $st_name .= "&id_course=" . $id_course . "&id_instance=" . $id_instance . ">";
                     $st_name .= $student_name . "</a>";
                     $st_history_count_norm = str_pad($st_history_count, 5, "0", STR_PAD_LEFT);
                     $st_history = "<!-- {$st_history_count_norm} --><a href=" . $http_root_dir . "/tutor/tutor_history.php?id_student=" . $id_student;
                     $st_history .= "&id_course=" . $id_course . "&id_course_instance=" . $id_instance . ">";
                     $st_history .= $st_history_count . "</a>";
                     $st_history_last_access = $studentObj->get_last_accessFN($id_instance, "T");
                     //$dati['date'] = $st_history_last_access;
                     $st_score_norm = str_pad($st_score, 5, "0", STR_PAD_LEFT);
                     $st_exercises = "<!-- {$st_score_norm} --><a href=" . $http_root_dir . "/tutor/tutor_exercise.php?id_student=" . $id_student;
                     $st_exercises .= "&id_course_instance=" . $id_instance . " class='dontwrap'>";
                     $st_exercises .= $st_score . " " . translateFN("su") . " " . $st_exer_number * ADA_MAX_SCORE . "</a>";
                     if (MODULES_TEST) {
                         $st_score_norm_test = str_pad($st_score_test, 5, "0", STR_PAD_LEFT);
                         $st_exercises_test = '<!-- ' . $st_score_norm_test . ' --><a href="' . MODULES_TEST_HTTP . '/tutor.php?op=test&id_course_instance=' . $id_instance . '&id_course=' . $id_course . '&id_student=' . $id_student . '" class="dontwrap">' . $st_score_test . ' ' . translateFN('su') . ' ' . $st_exer_number_test . '</a>';
                         $st_score_norm_survey = str_pad($st_score_survey, 5, "0", STR_PAD_LEFT);
                         $st_exercises_survey = '<!-- ' . $st_score_norm_survey . ' --><a href="' . MODULES_TEST_HTTP . '/tutor.php?op=survey&id_course_instance=' . $id_instance . '&id_course=' . $id_course . '&id_student=' . $id_student . '" class="dontwrap">' . $st_score_survey . ' ' . translateFN('su') . ' ' . $st_exer_number_survey . '</a>';
                     }
                     // user data
                     $dati_stude[$num_student]['id'] = $id_student;
                     $dati_stude[$num_student]['student'] = $st_name;
                     // history
                     $dati_stude[$num_student]['history'] = $st_history;
                     $tot_history_count += $st_history_count;
                     if ($st_history_last_access != "-") {
                         $dati_stude[$num_student]['last_access'] = "<a href=\"{$http_root_dir}/tutor/tutor_history_details.php?period=1&id_student={$id_student}&id_course_instance={$id_instance}&id_course={$id_course}\">" . $st_history_last_access . "</a>";
                         $dati['last_access'] = $studentObj->get_last_accessFN($id_instance, 'UT');
                     } else {
                         $dati_stude[$num_student]['last_access'] = $st_history_last_access;
                         $dati['last_access'] = null;
                     }
                     // exercises
                     $tot_exercises_score += $st_score;
                     $tot_exercises_number += $st_exer_number;
                     $dati_stude[$num_student]['exercises'] = $st_exercises;
                     $dati['exercises'] = $st_exer_number;
                     if (MODULES_TEST) {
                         $tot_exercises_score_test += $st_score_test;
                         $tot_exercises_number_test += $st_exer_number_test;
                         $dati_stude[$num_student]['exercises_test'] = $st_exercises_test;
                         $dati['exercises_test'] = $st_exer_number_test;
                         $tot_exercises_score_survey += $st_score_survey;
                         $tot_exercises_number_survey += $st_exer_number_survey;
                         $dati_stude[$num_student]['exercises_survey'] = $st_exercises_survey;
                         $dati['exercises_survey'] = $st_exer_number_survey;
                     }
                     // forum notes written
                     $dati_stude[$num_student]['added_notes'] = $added_notes;
                     $tot_added_notes += $added_nodes_count;
                     $dati['added_notes'] = $added_nodes_count;
                     // forum notes read
                     $dati_stude[$num_student]['read_notes'] = $read_notes;
                     $tot_read_notes += $read_notes_count;
                     $dati['read_notes'] = $read_notes_count;
                     // messages
                     //$mh = new MessageHandler("%d/%m/%Y - %H:%M:%S");
                     $mh = MessageHandler::instance(MultiPort::getDSN($_SESSION['sess_selected_tester']));
                     $sort_field = "data_ora desc";
                     // messages received
                     $msgs_ha = $mh->get_messages($id_student, ADA_MSG_SIMPLE, array("id_mittente", "data_ora"), $sort_field);
                     if (AMA_DataHandler::isError($msgs_ha)) {
                         $err_code = $msgs_ha->code;
                         $dati_stude[$num_student]['message_count_in'] = "-";
                     } else {
                         $user_message_count = count($msgs_ha);
                         $dati_stude[$num_student]['message_count_in'] = $user_message_count;
                         $tot_message_count += $user_message_count;
                     }
                     $tot_message_count_in += $user_message_count;
                     $dati['msg_in'] = $user_message_count;
                     // messages sent
                     $msgs_ha = $mh->get_sent_messages($id_student, ADA_MSG_SIMPLE, array("id_mittente", "data_ora"), $sort_field);
                     if (AMA_DataHandler::isError($msgs_ha)) {
                         $err_code = $msgs_ha->code;
                         $dati_stude[$num_student]['message_count_out'] = "-";
                     } else {
                         $user_message_count = count($msgs_ha);
                         $dati_stude[$num_student]['message_count_out'] = $user_message_count;
                         $tot_message_count += $user_message_count;
                     }
                     $tot_message_count_out += $user_message_count;
                     $dati['msg_out'] = $user_message_count;
                     //chat..
                     $msgs_ha = $mh->get_sent_messages($id_student, ADA_MSG_CHAT, array("id_mittente", "data_ora"), $sort_field);
                     if (AMA_DataHandler::isError($msgs_ha)) {
                         $err_code = $msgs_ha->code;
                         $dati_stude[$num_student]['chat'] = "-";
                     } else {
                         $chatlines_count_out = count($msgs_ha);
                         $dati_stude[$num_student]['chat'] = $chatlines_count_out;
                         $tot_chatlines_count_out += $chatlines_count_out;
                     }
                     $tot_chatlines_count_out += $chatlines_count_out;
                     $dati['chat'] = $chatlines_count_out;
                     //bookmarks..
                     include_once 'bookmark_class.inc.php';
                     $bookmarks_count = count(Bookmark::get_bookmarks($id_student));
                     $dati_stude[$num_student]['bookmarks'] = $bookmarks_count;
                     $tot_bookmarks_count += $bookmarks_count;
                     $dati['bookmarks'] = $bookmarks_count;
                     // activity index
                     if (empty($index_att)) {
                         // parametro passato alla funzione
                         if (empty($GLOBALS['index_activity_expression'])) {
                             //
                             if (!isset($bcount)) {
                                 $bcount = 1;
                             }
                             $index = $added_nodes_count * $npar + $st_history_count * $hpar + $user_message_count * $mpar + $st_exer_number * $epar + $bookmarks_count * $bcount + $chatlines_count_out * $cpar;
                         } else {
                             $index = eval($GLOBALS['index_activity_expression']);
                         }
                     } else {
                         $index = eval($index_att);
                     }
                     $dati_stude[$num_student]['index'] = $index;
                     //echo $index;
                     $tot_index += $index;
                     $dati['index'] = $index;
                     // level
                     $tot_level += $student_level;
                     $dati_stude[$num_student]['level'] = '<span id="studentLevel_' . $id_student . '">' . $student_level . '</span>';
                     $forceUpdate = false;
                     $linksHtml = $this->generateLevelButtons($id_student, $forceUpdate);
                     $dati_stude[$num_student]['level_plus'] = !is_null($linksHtml) ? $linksHtml : '-';
                     // inserting a row in table log_classi
                     $this->log_class_data($id_course, $id_instance, $dati);
                 }
             }
         }
         // average data
         $tot_students = $num_student + 1;
         $av_history = $tot_history_count / $tot_students;
         $av_exercises = $tot_exercises_score / $tot_students . " " . translateFN("su") . " " . floor($tot_exercises_number * ADA_MAX_SCORE / $tot_students);
         if (MODULES_TEST) {
             $av_exercises_test = round($tot_exercises_score_test / $tot_students, 2) . ' ' . translateFN('su') . ' ' . floor($tot_exercises_number_test / $tot_students);
             $av_exercises_survey = round($tot_exercises_score_survey / $tot_students, 2) . ' ' . translateFN('su') . ' ' . floor($tot_exercises_number_survey / $tot_students);
         }
         $av_added_notes = $tot_added_notes / $tot_students;
         $av_read_notes = $tot_read_notes / $tot_students;
         $av_message_count_in = $tot_message_count_in / $tot_students;
         $av_message_count_out = $tot_message_count_out / $tot_students;
         $av_chat_count_out = $tot_chatlines_count_out / $tot_students;
         $av_bookmarks_count = $tot_bookmarks_count / $tot_students;
         $av_index = $tot_index / $tot_students;
         $av_level = $tot_level / $tot_students;
         $av_student = $tot_students;
         $dati_stude[$av_student]['id'] = "-";
         $dati_stude[$av_student]['student'] = translateFN("Media");
         $dati_stude[$av_student]['history'] = round($av_history, 2);
         $dati_stude[$av_student]['last_access'] = "-";
         $dati_stude[$av_student]['exercises'] = '<span class="dontwrap">' . $av_exercises . '</span>';
         if (MODULES_TEST) {
             $dati_stude[$av_student]['exercises_test'] = '<span class="dontwrap">' . $av_exercises_test . '</span>';
             $dati_stude[$av_student]['exercises_survey'] = '<span class="dontwrap">' . $av_exercises_survey . '</span>';
         }
         $dati_stude[$av_student]['added_notes'] = round($av_added_notes, 2);
         $dati_stude[$av_student]['read_notes'] = round($av_read_notes, 2);
         $dati_stude[$av_student]['message_count_in'] = round($av_message_count_in, 2);
         $dati_stude[$av_student]['message_count_out'] = round($av_message_count_out, 2);
         $dati_stude[$av_student]['chat'] = round($av_chat_count_out, 2);
         $dati_stude[$av_student]['bookmarks'] = round($av_bookmarks_count, 2);
         $dati_stude[$av_student]['index'] = round($av_index, 2);
         $dati_stude[$av_student]['level'] = '<span id="averageLevel">' . round($av_level, 2) . '</span>';
         $dati_stude[$av_student]['level_plus'] = "-";
         // @author giorgio 16/mag/2013
         // was $dati_stude[$av_student]['level_minus'] = "-";
         // $dati_stude[$av_student]['level_less'] = "-";
         if (!empty($order)) {
             //var_dump($dati_stude);
             $dati_stude = masort($dati_stude, $order, 1, SORT_NUMERIC);
         }
         // TABLE LABELS
         $table_labels[0] = $this->generate_class_report_header();
         /**
          * @author giorgio 16/mag/2013
          * 
          * unset the unwanted columns data and labels. unwanted cols are defined in config/config_class_report.inc.php
          */
         $arrayToUse = 'report' . $type . 'ColArray';
         $this->clean_class_reportFN($arrayToUse, $table_labels, $dati_stude);
         return array('report_generation_date' => $report_generation_TS) + array_merge($table_labels, $dati_stude);
     } else {
         return null;
     }
 }
Exemple #8
0
 public function __set($name, $value)
 {
     $msg = '';
     switch ($value['error']) {
         case UPLOAD_ERR_CANT_WRITE:
             $msg = T('We are experiencing internal errors (%s). Please try again', 1);
             break;
         case UPLOAD_ERR_EXTENSION:
             $msg = T('Extension is not allowed');
             break;
         case UPLOAD_ERR_FORM_SIZE:
             $msg = T('File size was to big (%s)', 1);
             break;
         case UPLOAD_ERR_INI_SIZE:
             $msg = T('File size was to big (%s)', 2);
             break;
         case UPLOAD_ERR_NO_FILE:
             $msg = T('Please select a file to upload');
             break;
         case UPLOAD_ERR_NO_TMP_DIR:
             $msg = T('We are experiencing internal errors (%s). Please try again', 2);
             break;
         case UPLOAD_ERR_PARTIAL:
             $msg = T('File upload failed - please try again');
             break;
         case UPLOAD_ERR_OK:
         default:
             //Do nothing
             break;
     }
     if ($msg) {
         MessageHandler::instance()->flash($msg, true);
     }
     parent::__set($name, $value);
 }
Exemple #9
0
     echo $user_chat_report;
     //              header ("Connection: close");
     exit;
     break;
 case 'exportTable':
     // XLS-like
     $chat_report = "";
     if (!isset($id_chatroom)) {
         // ???
         if (isset($id_instance)) {
             $id_chatroom = $id_instance;
         } elseif (isset($sess_id_course_instance)) {
             $id_chatroom = $sess_id_course_instance;
         }
     }
     $mh = MessageHandler::instance($_SESSION['sess_selected_tester_dsn']);
     $chat_data = $mh->find_chat_messages($sess_user_id, ADA_MSG_CHAT, $id_chatroom, $fields_list = "", $clause = "", $ordering = "");
     if (is_array($chat_data)) {
         $chat_dataAr = array();
         $c = 0;
         $tbody_data = array();
         $export_log = translateFN('Data e ora') . ';' . translateFN('Utente') . ';' . translateFN('Messaggio') . PHP_EOL;
         foreach ($chat_data as $chat_msgAr) {
             if (is_numeric($chat_msgAr[0])) {
                 $sender_dataHa = $dh->_get_user_info($chat_msgAr[0]);
                 $user = $sender_dataHa['nome'] . ' ' . $sender_dataHa['cognome'];
                 $message = $chat_msgAr[1];
                 $data_ora = ts2dFN($chat_msgAr[2]) . " " . ts2tmFN($chat_msgAr[2]);
                 /*
                 *
                                             $row = array(
Exemple #10
0
 public function execute()
 {
     if (Settings::get(Settings::DEBUG, false)) {
         if (isset($_GET['__clearcache'])) {
             //Clear cache
             Dir::emptyDir(CACHEDIR, true);
         }
         if (isset($_GET['__clearview'])) {
             //Clear cache
             Dir::emptyDir(Dir::concat(CACHEDIR, 'view'), true);
         }
         if (isset($_GET['__clearjs'])) {
             //Clear cache
             Dir::emptyDir(Dir::concat(CACHEDIR, 'js'), true);
         }
         if (isset($_GET['__clearcss'])) {
             //Clear cache
             Dir::emptyDir(Dir::concat(CACHEDIR, 'css'), true);
         }
     }
     try {
         if (!String::isAlphaNum($this->controller)) {
             header("HTTP/1.0 404 Invalid url");
             throw new HttpNotFoundException(T('Invalid controller: %s', $this->controller));
         }
         if (!String::isAlphaNum($this->action)) {
             header("HTTP/1.1 404 Invalid url");
             throw new HttpNotFoundException(T('Invalid action: %s', $this->action));
         }
         $ctrlClass = ucfirst($this->controller) . 'Controller';
         $appViewFile = 'application';
         $viewFile = $this->getViewFile();
         if (!class_exists($ctrlClass)) {
             $ctrlFile = Dir::normalize(BASEDIR) . 'controller/' . $ctrlClass . '.php';
             if (!File::exists($ctrlFile)) {
                 header("HTTP/1.1 404 Controller not found");
                 throw new HttpNotFoundException(T('Controller not found: %s', $ctrlFile));
             }
             require_once $ctrlFile;
         }
         if (!class_exists($ctrlClass)) {
             header("HTTP/1.1 404 Controller not Found");
             throw new HttpNotFoundException(T('Controller not found: %s', $ctrlClass));
         }
         $ctrl = new $ctrlClass();
         $this->controllerInstance = $ctrl;
         if (!method_exists($ctrl, $this->action)) {
             header("HTTP/1.1 404 Action not Found");
             throw new HttpNotFoundException(T('Action not found: %s::%s', $ctrlClass, $this->action));
         }
         $action = $this->action;
         if (!$ctrl->getSkipView()) {
             try {
                 $view = new View($viewFile);
             } catch (Exception $e) {
                 //Ignore for now
             }
         }
         try {
             $data = $ctrl->{$action}();
         } catch (ValidationException $e) {
             //Do nothing...
         } catch (Interrupt $e) {
             //Do nothing...
         } catch (ErrorException $e) {
             MessageHandler::instance()->addError($e->getMessage());
         }
         if (!$data) {
             $data = $ctrl->getData();
         }
         if (!$ctrl->getSkipView()) {
             if ($view) {
                 $this->body = $view->render($data);
             } else {
                 if (!Request::isAjax()) {
                     header("HTTP/1.1 500 View not Found");
                     throw new Exception(T('View not found: %s', $viewFile));
                 }
             }
         }
     } catch (HttpNotFoundException $e) {
         trigger_error(sprintf("Path not found %s", self::getPath()), E_USER_ERROR);
         if (!Request::isAjax()) {
             Url::redirect('error', 'notfound');
         }
         Pimple::end();
     } catch (Exception $e) {
         header("HTTP/1.1 500 Internal error");
         if (Request::isAjax()) {
             $this->body = json_encode(array('msg' => $e->getMessage(), 'trace' => $e->getTraceAsString()));
         } else {
             if (Settings::get(Settings::DEBUG, false)) {
                 $body = $e->__toString();
                 if (!stristr($body, '<')) {
                     $body = '<pre>' . $body . '</pre>';
                 }
                 $this->body = $body;
             } else {
                 trigger_error(sprintf("Unexpected exception thrown in %s:\n\t%s", self::getPath(), $e->__toString()), E_USER_ERROR);
                 Url::redirect('error', 'internal');
             }
         }
     }
     $this->view = new View($appViewFile);
 }
Exemple #11
0
 /**
  * Should be included at the bottom of the page - to enable pimple error|status|warning messages
  */
 protected function tagMessages($attrs)
 {
     $msgs = MessageHandler::instance()->getMessages();
     MessageHandler::instance()->clear();
     $output = '<div class="pimple-messages">';
     foreach ($msgs as $msg) {
         $class = $msg->isError() ? 'error' : 'success';
         if (!$msg->getField()) {
             $output .= sprintf('<div class="message %s">%s</div>', $class, $msg->getText());
         }
     }
     return $output . '</div>';
 }
Exemple #12
0
  * Obtain note data
  */
 $note_data = $dh->get_node_info($id_node);
 if (AMA_DataHandler::isError($note_data)) {
     $errObj = new ADA_Error($note_data, translateFN("Errore nell'ottenimento dei dati relativi alla nota da promuovere"));
 }
 $note_title = $note_data['name'];
 /*
  * Prepare the text of the message
  */
 $message_text = sprintf(translateFN("Il tutor %s segnala la seguente nota per la promozione a nodo del corso."), $user_name);
 $note_url = $http_root_dir . '/browsing/view.php?id_course=' . $id_course . '&id_course_instance=' . $id_course_instance . '&id_node=' . $id_node;
 $link_to_note = CDOMElement::create('a', "href:{$note_url}");
 $link_to_note->addChild(new CText($note_title));
 $message_text .= $link_to_note->getHtml();
 $message_handler = MessageHandler::instance();
 $message_ha['destinatari'] = "{$author_data['username']}, {$user_name}";
 $message_ha['data_ora'] = "now";
 $message_ha['tipo'] = ADA_MSG_SIMPLE;
 $message_ha['mittente'] = $user_name;
 $message_ha['testo'] = $message_text;
 $message_ha['titolo'] = translateFN("Promozione di una nota a nodo");
 $message_ha['priorita'] = 2;
 $result = $message_handler->send_message($message_ha);
 if (AMA_DataHandler::isError($result)) {
     $errObj = new ADA_Error($result, translateFN("Errore nell'invio del messaggio di suggerimento promozione nota."));
 }
 $status = translateFN("Proposta di promozione inviata all'autore del corso");
 header("Location: {$http_root_dir}/browsing/view.php?status={$status}");
 exit;
 break;
Exemple #13
0
 public static function getUserAppointment(ADALoggableUser $userObj, $appointment_id)
 {
     $data_Ar = self::geTesterAndMessageId($appointment_id);
     $mh = MessageHandler::instance(self::getDSN($data_Ar['tester']));
     $msg_ha = $mh->get_message($userObj->getId(), $data_Ar['message_id']);
     if (AMA_DataHandler::isError($msg_ha)) {
         /*
          * Return a ADA_Error object with delayed error handling
          */
         return new ADA_Error($msg_ha, translateFN('Errore durante lettura appuntamento'), NULL, NULL, NULL, NULL, TRUE);
     }
     return $msg_ha;
 }
Exemple #14
0
     $message = translateFN('An error occurred while performing your request. Please try again later.');
     header('Location:' . HTTP_ROOT_DIR . "/browsing/forget.php?message={$message}");
     exit;
 }
 $token = $tokenObj->getTokenString();
 $titolo = translateFN("Password changing request");
 $testo = translateFN("An ADA user with username: "******" requested to change his/her password in ADA");
 $link = HTTP_ROOT_DIR . "/browsing/forget.php?uid={$user_id}&tok={$token}";
 $testo .= PHP_EOL . PHP_EOL . translateFN(" To confirm this request, please follow this link:");
 $testo .= " " . $link;
 // $mh = MessageHandler::instance(MultiPort::getDSN($tester)); /* FIXME */
 // should we user common DB?
 $common_db_dsn = ADA_COMMON_DB_TYPE . '://' . ADA_COMMON_DB_USER . ':' . ADA_COMMON_DB_PASS . '@' . ADA_COMMON_DB_HOST . '/' . ADA_COMMON_DB_NAME;
 $mh = MessageHandler::instance($common_db_dsn);
 // prepare message to send
 $message_ha = array();
 $message_ha['titolo'] = $titolo;
 $message_ha['testo'] = $testo;
 $message_ha['destinatari'] = array($username);
 $message_ha['data_ora'] = "now";
 $message_ha['tipo'] = ADA_MSG_MAIL;
 $message_ha['mittente'] = $adm_uname;
 // delegate sending to the message handler
 $res = $mh->send_message($message_ha);
 if (AMA_DataHandler::isError($res)) {
     //	  $errObj = new ADA_Error($res,translateFN('Impossibile spedire il messaggio'),
     //	  NULL,NULL,NULL,$error_page.'?err_msg='.urlencode(translateFN('Impossibile spedire il messaggio')));
 }
 //	} else {
Exemple #15
0
 */
if (!$userObj->isSuper() && $op == 'tutor') {
    $op = null;
}
switch ($op) {
    case 'tutor':
        $help = '';
        $fieldsAr = array('nome', 'cognome', 'username');
        $tutorsAr = $dh->get_tutors_list($fieldsAr);
        if (!AMA_DB::isError($tutorsAr) && is_array($tutorsAr) && count($tutorsAr) > 0) {
            $tableDataAr = array();
            $imgDetails = CDOMElement::create('img', 'src:' . HTTP_ROOT_DIR . '/layout/' . $_SESSION['sess_template_family'] . '/img/details_open.png');
            $imgDetails->setAttribute('title', translateFN('visualizza/nasconde i dettagli del tutor'));
            $imgDetails->setAttribute('style', 'cursor:pointer;');
            $imgDetails->setAttribute('class', 'tooltip');
            $mh = MessageHandler::instance(MultiPort::getDSN($_SESSION['sess_selected_tester']));
            foreach ($tutorsAr as $aTutor) {
                // open details button
                $imgDetails->setAttribute('onclick', "toggleTutorDetails(" . $aTutor[0] . ",this);");
                // received messages
                $receivedMessages = 0;
                $msgs_ha = $mh->get_messages($aTutor[0], ADA_MSG_SIMPLE);
                if (!AMA_DataHandler::isError($msgs_ha)) {
                    $receivedMessages = count($msgs_ha);
                }
                // sent messages
                $sentMessages = 0;
                $msgs_ha = $mh->get_sent_messages($aTutor[0], ADA_MSG_SIMPLE);
                if (!AMA_DataHandler::isError($msgs_ha)) {
                    $sentMessages = count($msgs_ha);
                }