/** * * @param Node $n The node for which calculate the previous and next node link * @param array $params */ public function __construct(Node $n, $params = array()) { $this->_currentNode = $n->id; $prevId = DataValidator::validate_node_id($params['prevId']); if ($prevId !== false) { $this->_previousNode = $prevId; } else { $this->findPreviousNode($n, $params['userLevel']); } $nextId = DataValidator::validate_node_id($params['nextId']); if ($nextId !== false) { $this->_nextNode = $nextId; } else { $this->findNextNode($n, $params['userLevel']); } /** * @author giorgio 08/ott/2013 * check if this is a node wich has been generated when creating a test. * If it is, next node is the first topic of the test. * BUT, I'll pass the computed $this->_nextNode to give a callBack point * to be used when user is in the last topic of the test. */ if (MODULES_TEST && strpos($n->type, (string) constant('ADA_PERSONAL_EXERCISE_TYPE')) === 0) { if (isset($GLOBALS['dh'])) { $GLOBALS['dh']->disconnect(); } $test_db = AMATestDataHandler::instance(MultiPort::getDSN($_SESSION['sess_selected_tester'])); $res = $test_db->test_getNodes(array('id_nodo_riferimento' => $n->id)); if (!empty($res) && count($res) == 1 && !AMA_DataHandler::isError($res)) { $node = array_shift($res); $this->_nextTestNode = $node['id_nodo']; } /** * @author giorgio 06/nov/2013 * must check if computed $this->_previousNode points to a test * and get last topic if it does. */ if (!is_null($this->_previousNode)) { $res = $test_db->test_getNodes(array('id_nodo_riferimento' => $this->_previousNode)); } else { $res = array(); } if (!empty($res) && count($res) == 1 && !AMA_DataHandler::isError($res)) { $node = array_shift($res); $test = NodeTest::readTest($node['id_nodo'], $test_db); $this->_prevTestTopic = count($test->_children); $this->_prevTestNode = $node['id_nodo']; } $test_db->disconnect(); } }
/* * 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)); /*
} } 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'))); }
} } if ($id_profile == AMA_TYPE_STUDENT && $log_enabled) { $user_level = (string) $userObj->get_student_level($sess_id_user, $sess_id_course_instance); $user_score = (string) $userObj->get_student_score($sess_id_user, $sess_id_course_instance); $user_history = $userObj->history; } /** * service completeness */ if ($id_profile == AMA_TYPE_STUDENT && defined('MODULES_SERVICECOMPLETE') && MODULES_SERVICECOMPLETE) { if (isset($courseInstanceObj) && isset($courseObj) && isset($userObj) && is_object($courseInstanceObj) && is_object($courseObj) && is_object($userObj)) { if ($user_status != ADA_SERVICE_SUBSCRIPTION_STATUS_COMPLETED) { // need the service-complete module data handler require_once MODULES_SERVICECOMPLETE_PATH . '/include/init.inc.php'; $mydh = AMACompleteDataHandler::instance(MultiPort::getDSN($_SESSION['sess_selected_tester'])); // load the conditionset for this course $conditionSet = $mydh->get_linked_conditionset_for_course($courseObj->getId()); $mydh->disconnect(); if ($conditionSet instanceof CompleteConditionSet) { // evaluate the conditionset for this instance ID and course ID $is_course_instance_complete = $conditionSet->evaluateSet(array($courseInstanceObj->getId(), $userObj->getId())); } else { $is_course_instance_complete = false; } // if course is complete, save this information to the db if ($is_course_instance_complete) { require_once ROOT_DIR . '/switcher/include/Subscription.inc.php'; $s = new Subscription($userObj->getId(), $courseInstanceObj->getId()); $s->setSubscriptionStatus(ADA_SERVICE_SUBSCRIPTION_STATUS_COMPLETED); if (isset($userObj->livello) && intval($userObj->livello) > 0) {
$chatroom_ha['id_chat_owner'] = $sess_id_user; } $chatroom_ha = array('chat_title' => $course_data['titolo'], 'chat_topic' => translateFN('Discussione sui contenuti del corso'), 'start_time' => $start_time, 'end_time' => $end_time, 'max_utenti' => '999', 'id_course_instance' => $id_instance); $result = ChatRoom::add_chatroomFN($chatroom_ha); if (AMA_DataHandler::isError($result)) { // gestire l'errore } } else { // e' un errore, gestire } } else { /* * An existing chatroom with duration == class duration * already exists, so update this chatroom start and end time. */ $chatroomObj = new Chatroom($id_chatroom, MultiPort::getDSN($_SESSION['sess_selected_tester'])); $id_tutor = $dh->course_instance_tutor_get($id_instance); if (!AMA_DataHandler::isError($id_tutor)) { $chatroom_data['id_chat_owner'] = $id_tutor; } else { $chatroom_data['id_chat_owner'] = $sess_id_user; } $chatroom_data = array('start_time' => $start_time, 'end_time' => $end_time, 'max_utenti' => '999'); $result = $chatroomObj->set_chatroomFN($chatroomObj->id_chatroom, $chatroom_data); if (AMA_DataHandler::isError($result)) { // gestire l'errore } } header('Location: list_instances.php?id_course=' . $courseObj->getId()); exit; }
protected static function fillAddressBook(ADALoggableUser $userObj, $user_types_Ar = array()) { $user_type = $userObj->getType(); $common_dh = $GLOBALS['common_dh']; $dh = $GLOBALS['dh']; // this tells get_users_by_type method to get nome, cognome.... $retrieve_extended_data = true; if (!is_array($user_types_Ar[$user_type]) || empty($user_types_Ar[$user_type])) { return FALSE; } switch ($user_type) { case AMA_TYPE_ADMIN: /* * Ottieni tutti i practitioner, gli autori e gli switcher da tutti i * tester */ // FIXME: differisce dagli altri casi !!! $users[] = $common_dh->get_users_by_type($user_types_Ar[AMA_TYPE_ADMIN], $retrieve_extended_data); if (AMA_Common_DataHandler::isError($users)) { // Gestione errore } break; case AMA_TYPE_SWITCHER: /* * Ottieni tutti i practitioner e gli utenti dal suo tester */ $tester = $userObj->getDefaultTester(); $tester_dh = AMA_DataHandler::instance(MultiPort::getDSN($tester)); $tester_info_Ar = $common_dh->get_tester_info_from_pointer($tester); $tester_name = $tester_info_Ar[1]; $users[$tester_name] = $tester_dh->get_users_by_type($user_types_Ar[AMA_TYPE_SWITCHER], $retrieve_extended_data); if (AMA_Common_DataHandler::isError($users)) { $users[$tester_name] = array(); } /* * Ottiene tutti i practitioner presenti sul tester */ // $practitioners_Ar = $tester_dh->get_users_by_type(array(AMA_TYPE_TUTOR), $retrieve_extended_data); // if(AMA_DataHandler::isError($practitioners_Ar) || !is_array($practitioners_Ar)) { // $practitioners_Ar = array(); // } /* * Ottiene tutti gli utenti che hanno richiesto un servizio sul tester * e che sono in attesa di assegnamento ad un practitioner */ // $users_Ar = $tester_dh->get_registered_students_without_tutor(); // if(AMA_DataHandler::isError($users_Ar) || !is_array($users_Ar)) { // $users_Ar = array(); // } // $users[$tester_name] = array_merge($practitioners_Ar, $users_Ar); break; case AMA_TYPE_TUTOR: /* * Ottieni lo switcher del suo tester, gli utenti con i quali è in relazione, * eventualmente gli altri practitioner sul suo tester */ $tester = $userObj->getDefaultTester(); $tester_dh = AMA_DataHandler::instance(MultiPort::getDSN($tester)); $tester_info_Ar = $common_dh->get_tester_info_from_pointer($tester); $tester_name = $tester_info_Ar[1]; if (in_array(AMA_TYPE_STUDENT, $user_types_Ar[$user_type])) { /* * STUDENTS */ // $users[$tester_name] = $tester_dh->get_list_of_tutored_users($userObj->id_user); if (!$userObj->isSuper()) { $students_Ar = $tester_dh->get_list_of_tutored_unique_users($userObj->id_user); } else { $students_Ar = $tester_dh->get_users_by_type(array(AMA_TYPE_STUDENT), $retrieve_extended_data); } // $users[$tester_name] = $tester_dh->get_users_by_type($user_types_Ar[AMA_TYPE_TUTOR], $retrieve_extended_data); if (AMA_DataHandler::isError($students_Ar) || !is_array($students_Ar)) { $students_Ar = array(); } } else { $students_Ar = array(); } if (in_array(AMA_TYPE_TUTOR, $user_types_Ar[$user_type])) { /* * TUTORS */ $tutors_Ar = $tester_dh->get_users_by_type(array(AMA_TYPE_TUTOR), $retrieve_extended_data); if (AMA_DataHandler::isError($tutors_Ar) || !is_array($tutors_Ar)) { $tutors_Ar = array(); } } else { $tutors_Ar = array(); } if (in_array(AMA_TYPE_SWITCHER, $user_types_Ar[$user_type])) { /* * SWITCHERS */ $switchers_Ar = $tester_dh->get_users_by_type(array(AMA_TYPE_SWITCHER), $retrieve_extended_data); if (AMA_DataHandler::isError($switchers_Ar) || !is_array($switchers_Ar)) { $switchers_Ar = array(); } } else { $switchers_Ar = array(); } $users[$tester_name] = array_merge($tutors_Ar, $students_Ar, $switchers_Ar); break; case AMA_TYPE_STUDENT: /* * Se sono all'interno di un tester, vedo solo i practitioner di questo * tester con i quali sono in relazione * Se sono nella home dell'utente, vedo tutti i practitioner di tutti i * tester con i quali sono in relazione * * Come faccio a capirlo qui? posso Verificare che sess_selected_tester == ADA_DEFAULT_TESTER */ if (MultiPort::isUserBrowsingThePublicTester()) { // home di user o navigazione nei contenuti pubblici $testers = $userObj->getTesters(); foreach ($userObj->getTesters() as $tester) { if ($tester != ADA_PUBLIC_TESTER or count($testers) == 1) { $tester_dh = AMA_DataHandler::instance(MultiPort::getDSN($tester)); $tester_info_Ar = $common_dh->get_tester_info_from_pointer($tester); $tester_name = $tester_info_Ar[1]; $tutors_Ar = $tester_dh->get_tutors_for_student($userObj->getId()); if (AMA_DataHandler::isError($tutors_Ar) || !is_array($tutors_Ar)) { $tutors_Ar = array(); } $tutors_Ar = array_unique($tutors_Ar, SORT_REGULAR); $switcher_Ar = $tester_dh->get_users_by_type(array(AMA_TYPE_SWITCHER), $retrieve_extended_data); if (AMA_DataHandler::isError($switcher_Ar) || !is_array($switcher_Ar)) { $switcher_Ar = array(); } /* * OTHER STUDENTS RELATED TO USER */ $subscribed_instances = $tester_dh->get_id_course_instances_for_this_student($userObj->getId()); $students_Ar = $tester_dh->get_unique_students_for_course_instances($subscribed_instances); if (AMA_DataHandler::isError($students_Ar) || !is_array($students_Ar)) { $students_Ar = array(); } /* foreach ($subscribed_instances as $subscribed_instance) { $subscribed_instance_id = $subscribed_instance['id_istanza_corso']; $students_Ar = array_merge($tester_dh->get_students_for_course_instance($subscribed_instance_id)); } * */ $users[$tester_name] = array_merge($tutors_Ar, $switcher_Ar, $students_Ar); } } } else { $tester = $_SESSION['sess_selected_tester']; $tester_info_Ar = $common_dh->get_tester_info_from_pointer($tester); $tester_name = $tester_info_Ar[1]; $tester_dh = AMA_DataHandler::instance(MultiPort::getDSN($tester)); /* * GET TUTORS OF TESTER */ $tutors_Ar = $tester_dh->get_tutors_for_student($userObj->getId()); if (AMA_DataHandler::isError($tutors_Ar) || !is_array($tutors_Ar)) { $tutors_Ar = array(); } $tutors_Ar = array_unique($tutors_Ar, SORT_REGULAR); /* * GET SWITCHER OF TESTER */ $switcher_Ar = $tester_dh->get_users_by_type(array(AMA_TYPE_SWITCHER), $retrieve_extended_data); if (AMA_DataHandler::isError($switcher_Ar) || !is_array($switcher_Ar)) { $switcher_Ar = array(); } /* * OTHER STUDENTS RELATED TO USER */ $subscribed_instances = $tester_dh->get_id_course_instances_for_this_student($userObj->getId()); $students_Ar = $tester_dh->get_unique_students_for_course_instances($subscribed_instances); if (AMA_DataHandler::isError($students_Ar) || !is_array($students_Ar)) { $students_Ar = array(); } $users[$tester_name] = array_merge($tutors_Ar, $switcher_Ar, $students_Ar); } break; case AMA_TYPE_AUTHOR: default: return FALSE; } return $users; }
/** * Performs basic controls before entering this module */ $neededObjAr = array(AMA_TYPE_AUTHOR => array('layout', 'node', 'course', 'course_instance')); require_once ROOT_DIR . '/include/module_init.inc.php'; //$self = whoami(); $self = 'form'; require_once ROOT_DIR . '/services/include/author_functions.inc.php'; $layout_dataAr['node_type'] = $self; $online_users_listing_mode = 2; $online_users = ADAGenericUser::get_online_usersFN($id_course_instance, $online_users_listing_mode); require_once MODULES_TEST_PATH . '/config/config.inc.php'; require_once MODULES_TEST_PATH . '/include/management/managementTest.inc.php'; require_once MODULES_TEST_PATH . '/include/management/rootManagementTest.inc.php'; //needed to promote AMADataHandler to AMATestDataHandler. $sess_selected_tester is already present in session $GLOBALS['dh'] = AMATestDataHandler::instance(MultiPort::getDSN($_SESSION['sess_selected_tester'])); /* * Generazione dei form per l'inserimento dell'esercizio. * */ require_once MODULES_TEST_PATH . '/include/management/questionManagementTest.inc.php'; $management = new QuestionManagementTest($_GET['action'], $_GET['id_question'], $_GET['id_test']); $form_return = $management->run(); // per la visualizzazione del contenuto della pagina $banner = (include $root_dir . '/include/banner.inc.php'); $content_dataAr = array('head' => $head_form, 'banner' => $banner, 'path' => $form_return['path'], 'form' => $form_return['html'], 'status' => $form_return['status'], 'user_name' => $user_name, 'user_type' => $user_type, 'messages' => $user_messages->getHtml(), 'agenda' => $user_agenda->getHtml(), 'title' => $node_title, 'course_title' => $course_title, 'back' => $back); $content_dataAr['notes'] = $other_node_data['notes']; $content_dataAr['personal'] = $other_node_data['private_notes']; if ($reg_enabled) { $content_dataAr['add_bookmark'] = $add_bookmark; } else {
function _get_course_info($id_course) { $common_dh = $GLOBALS['common_dh']; $serviceAr = $common_dh->get_service_info_from_course($id_course); if (!AMA_DataHandler::isError($serviceAr)) { $service_name = $serviceAr[1]; $service_level = $serviceAr[3]; $service_duration = $serviceAr[4]; $service_max_meeting = $serviceAr[5]; $service_max_meeting_time = $serviceAr[7] / 60; } $providerAr = $common_dh->get_tester_info_from_id_course($id_course); if (!AMA_DataHandler::isError($providerAr)) { $provider = $providerAr['puntatore']; $provider_dsn = MultiPort::getDSN($provider); $provider_name = $providerAr['nome']; $service_country = $providerAr['nazione'] . "/" . $providerAr['provincia']; } $provider_dh = AMA_DataHandler::instance($provider_dsn); $dataHa = $provider_dh->get_course($id_course); if (AMA_DataHandler::isError($dataHa) || !is_array($dataHa)) { $infomsg = $dataHa->getMessage(); if ($dataHa->code == AMA_ERR_NOT_FOUND) { $service_description = translateFN("Il provider non fornisce attualmente questo servizio"); } // header("Location: $error?err_msg=$msg"); //return $infomsg; } else { if (!empty($dataHa['nome'])) { $course_infoHa = array(); // 1.info from table modello_corso $service_title = $dataHa['titolo']; // $service_name = $dataHa['nome']; // 2. description of instance from table modello_corso $service_instance_description = $dataHa['descr']; // 3. full description from node id_nodo_iniziale $id_desc = $id_course . "_" . $dataHa['id_nodo_iniziale']; $user_level = "999"; $nodeHa = $provider_dh->get_node_info($id_desc); if (AMA_DataHandler::isError($nodeHa)) { // $errorObj = new ADA_error($nodeHa); //FIXME: mancano gli altri dati $service_description = translateFN("Il provider non fornisce attualmente questo servizio"); } else { $service_description = $nodeHa['text']; } } else { $service_description = translateFN("Il provider non fornisce attualmente questo servizio"); } } // check on level? /* if ($service_level > 1){ $require_link = "<a href=" . HTTP_ROOT_DIR . "/browsing/registration.php?id_course=$id_course>" .translateFN('Richiedi'). "</a>"; } else { $require_link = "<a href=" . HTTP_ROOT_DIR . "/browsing/view.php?id_course=$id_course&id_node=$id_desc>" .translateFN('Entra'). "</a>"; } */ if ($service_instance_description == NULL) { $service_instance_description = level2descriptionFN($service_level); } $service_div = CDOMElement::create('div', 'id:service_info'); $thead_data = array(translateFN('Fornitore'), translateFN('Nome'), translateFN('Paese'), translateFN('Livello'), translateFN('Durata (gg)'), translateFN('Numero incontri'), translateFN('Durata incontro (minuti)'), translateFN('Descrizione servizio'), translateFN('Descrizione dettagliata')); $tbody_dataAr = array(); $tbody_dataAr[] = array($provider_name, $service_name, $service_country, level2stringFN($service_level), $service_duration, $service_max_meeting, $service_max_meeting_time, $service_description, $service_instance_description); $element_attributes = ""; $serviceTable = BaseHtmlLib::tableElement($element_attributes, $thead_data, $tbody_dataAr); $service_div->addChild($serviceTable); $service_data = $service_div->getHtml(); return $service_data; }
/** * runs the actual import * * @return Ambigous AMA_Error on error |array recpArray on success * * @access public */ public function runImport() { $count = 0; $zipFileName = ADA_UPLOAD_PATH . $this->_importFile; $zip = new ZipArchive(); if ($zip->open($zipFileName)) { $XMLfile = $zip->getFromName(XML_EXPORT_FILENAME); $XMLObj = new SimpleXMLElement($XMLfile); $this->_progressResetValues(substr_count($XMLfile, '</nodo>') + substr_count($XMLfile, '<survey ') + substr_count($XMLfile, '</test>')); foreach ($XMLObj as $objName => $course) { // first level object must be 'modello_corso' if ($objName === 'modello_corso') { $count++; // get the attributes as local vars // e.g. attributed exportedId=107 becomes // a local var named $exportedId, initialized to 107 as a string foreach ($course->attributes() as $name => $val) { ${$name} = (string) $val; } // as a result of this foreach we have a php var for any XML object attribute // var_dump ($exportedId); should neither raise an error nor dump a null value. $this->_courseOldID = $exportedId; /** * sets the log file name that will be used from now on! */ $this->_logFile = MODULES_IMPEXPORT_LOGDIR . "import-" . $this->_courseOldID . "_" . date('d-m-Y_His') . ".log"; $this->_logMessage('**** IMPORT STARTED at ' . date('d/m/Y H:i:s') . '(timestamp: ' . $this->_dh->date_to_ts('now') . ') ****'); $this->_progressSetTitle((string) $course->titolo); /** * ADDS THE COURSE TO THE APPROPIATE TABLES */ if (!self::$_DEBUG) { if (is_null($this->_selectedCourseID)) { $courseNewID = $this->_add_course($course); /** * this is a new course you want, first node * is going to be the root of the course (i.e. zero) * Setting selectedNodeID will make the running code * do the trick! */ $this->_selectedNodeID = null; } else { $courseNewID = $this->_selectedCourseID; } if (AMA_DB::isError($courseNewID)) { return $courseNewID; } } else { $courseNewID = 123 * $count; } /** * NOW ADD NODES, TESTS AND SURVEYS */ foreach ($this->_specialNodes as $groupName) { $method = '_import' . ucfirst(strtolower($groupName)); $this->_logMessage(__METHOD__ . ' Saving ' . $groupName . ' by calling method: ' . $method); if ($groupName === 'tests' || $groupName === 'surveys') { // prepares the mapping array by emptying it if ($groupName === 'tests') { if (isset($this->_testNodeIDMapping)) { unset($this->_testNodeIDMapping); } $this->_testNodeIDMapping = array(); } // prepares the test data handler $this->_dh->disconnect(); $this->_dh = AMATestDataHandler::instance(MultiPort::getDSN($this->_selectedTester)); } /** * calls a method named _import<groupName> foreach special node. * e.g. for nodes it will call _importNodi, for tests _importTests.... */ if (method_exists($this, $method) && !empty($course->{$groupName})) { $specialVal = $this->{$method}($course->{$groupName}, $courseNewID); // if it's an error return it right away if (AMA_DB::isError($specialVal)) { $this->_logMessage(__METHOD__ . ' Error saving ' . $groupName . '. DB returned the following:'); $this->_logMessage(print_r($specialVal, true)); return $specialVal; } else { $this->_logMessage(__METHOD__ . ' Saving ' . $groupName . ' successfully ended'); $this->_recapArray[$courseNewID][$groupName] = $specialVal; } } if ($groupName === 'nodi') { // save all the links and clean the array $this->_saveLinks($courseNewID); // after links have been saved, update inernal links pseudo html in proper nodes $this->_updateInternalLinksInNodes($courseNewID); } else { if ($groupName === 'tests' || $groupName === 'surveys') { // restores the import/export data handler $this->_dh->disconnect(); $this->_dh = AMAImpExportDataHandler::instance(MultiPort::getDSN($this->_selectedTester)); if ($groupName === 'tests') { $this->_updateTestLinksInNodes($courseNewID); } } } } // $this->_updateTestLinksInNodes ( $courseNewID ); } // if ($objName === 'modello_corso') $this->_logMessage('**** IMPORT ENDED at ' . date('d/m/Y H:i:s') . '(timestamp: ' . $this->_dh->date_to_ts('now') . ') ****'); $this->_logMessage('If there\'s no zip log below, this is a multi course import: pls find unzip log at the end of the last course log'); } // foreach ($XMLObj as $objName=>$course) // extract the zip files to the appropriate media dir $this->_unzipToMedia($zip); $zip->close(); if (!self::$_DEBUG) { unlink($zipFileName); } } $this->_progressDestroy(); return $this->_recapArray; }
/** * checks if the passed object type and id are coming from the public tester. * If true sets the needed GLOBALS['dh'] session variables accordingly. * * @param string $objType either 'course' or 'node' * @param string $objID object id to be checked and loaded if need be * * return true if invalid has to be set to true on the caller */ function checkAndSetPublicTester($objType, $objID) { $common_dh = $GLOBALS['common_dh']; if ($objType !== 'course' || is_null($objID)) { $tmp_id_course = isset($_REQUEST['id_course']) ? DataValidator::is_uinteger($_REQUEST['id_course']) : false; if ($tmp_id_course === false) { $tmp_id_course = isset($_REQUEST['id_node']) ? substr($_REQUEST['id_node'], 0, strpos($_REQUEST['id_node'], '_')) : false; } if ($tmp_id_course === false) { $tmp_id_course = isset($_SESSION['sess_id_course']) ? DataValidator::is_uinteger($_SESSION['sess_id_course']) : false; } if ($tmp_id_course === false) { $tmp_id_course = isset($_SESSION['sess_id_node']) ? substr($_SESSION['sess_id_node'], 0, strpos($_SESSION['sess_id_node'], '_')) : false; } } else { $tmp_id_course = $objID; } if ($tmp_id_course !== false) { // get the tester for the passed id_course $tester_infoAr = $common_dh->get_tester_info_from_id_course($tmp_id_course); // get the service info for the passed id_course $service_inforAr = $common_dh->get_service_type_info_from_course($tmp_id_course); // check that the tester is valid and is the public one and // check that the service is valid and is a public one if (!AMA_DB::isError($tester_infoAr) && is_array($tester_infoAr) && isset($tester_infoAr['puntatore']) && $tester_infoAr['puntatore'] == ADA_PUBLIC_TESTER && !AMA_DB::isError($service_inforAr) && is_array($service_inforAr) && isset($service_inforAr['isPublic']) && intval($service_inforAr['isPublic']) !== 0) { // save the dh, if a restrore is needed afterwards $olddh = $GLOBALS['dh']; // load the dh $dh = AMA_DataHandler::instance(MultiPort::getDSN($tester_infoAr['puntatore'])); if (!AMA_DB::isError($dh)) { // check the object if ($objType == 'node') { $dataHa = $dh->get_node_info($objID); if (AMA_DB::isError($dataHa) || !is_array($dataHa)) { $retval = true; // restore the saved datahandler $GLOBALS['dh'] = $olddh; } else { $retval = false; // set the datahandler $GLOBALS['dh'] = $dh; $_SESSION['sess_id_node'] = $objID; $_SESSION['sess_id_course'] = $tmp_id_course; } } else { if ($objType == 'course') { // set the datahandler $GLOBALS['dh'] = $dh; $sess_courseObj = read_course($objID); if (AMA_DB::isError($sess_courseObj) || !$sess_courseObj instanceof Course) { $retval = true; // restore the saved datahandler $GLOBALS['dh'] = $olddh; } else { $retval = false; $_SESSION['sess_courseObj'] = $sess_courseObj; $_SESSION['sess_id_course'] = $objID; } } } } } } return isset($retval) ? $retval : true; }
/** * removeUserExtraData * * Removes a row from the user extra datas. * * @author giorgio 20/giu/2013 * * @param ADALoggableUser $userObj user for which to delete the row * @param int $extraTableId row id to be deleted * @param string $extraTableClass class of row to be deleted * * @return boolean on error | query result * * @access public */ public static function removeUserExtraData(ADALoggableUser $userObj, $extraTableId = null, $extraTableClass = false) { if ($extraTableId !== null && $extraTableClass !== false) { $user_id = $userObj->getId(); $testers = $userObj->getTesters(); if (!is_array($testers)) { $testers = array(); } if ($user_id == 0) { return FALSE; } foreach ($testers as $tester) { $tester_dh = AMA_DataHandler::instance(MultiPort::getDSN($tester)); $result = $tester_dh->remove_user_extraRow($user_id, $extraTableId, $extraTableClass); } return $result; } else { return false; } }
/** * Sets the terminated status for the passed courseId and courseInstanceId * It is usually called from user.php when the user has a subscried status * and the subscription_date + duration_subscription is in the past. * * @param number $courseId * @param number $courseInstanceId * * @return AMA_Error on error or true on success * * @access public * * @author giorgio 03/apr/2015 */ public function setTerminatedStatusForInstance($courseId, $courseInstanceId) { $common_dh = $GLOBALS['common_dh']; require_once ROOT_DIR . '/switcher/include/Subscription.inc.php'; $s = new Subscription($this->getId(), $courseInstanceId); $s->setSubscriptionStatus(ADA_STATUS_TERMINATED); $s->setStartStudentLevel(null); // null means no level update // search the provider of the current iteration course $courseProv = $common_dh->get_tester_info_from_id_course($courseId); if (!AMA_DB::isError($courseProv) && is_array($courseProv) && isset($courseProv['puntatore'])) { // save the datahandler $savedDH = $GLOBALS['dh']; // set the datahandler to be used $GLOBALS['dh'] = AMA_DataHandler::instance(MultiPort::getDSN($courseProv['puntatore'])); // update the subscription $retval = Subscription::updateSubscription($s); // restore the datahandler $GLOBALS['dh'] = $savedDH; $GLOBALS['dh']->disconnect(); } return isset($retval) ? $retval : null; }
/** * gets a list of the available login providers found in the DB * * If in a multiprovider environment, common db is used * else first it's searched the provider db and if no * module_login_providers table is found there, use common * * @param bool $enabled true if only enabled providers, false if only disabled, null for all providers * @param bool $getData true, to return all provider's data. defaults to false: return className only * * @return array with provider id as the key and implementing className as value * * @access public */ public static function getLoginProviders($enabled = true, $getData = false) { /** * If not multiprovider, the AMALoginDataHandler must check * if module's own tables are in the user_provider DB and use them * or the ones in the common db if they're not found in the provider DB */ if (!MULTIPROVIDER && isset($GLOBALS['user_provider']) && !empty($GLOBALS['user_provider'])) { $dsn = MultiPort::getDSN($GLOBALS['user_provider']); } else { $dsn = null; } $res = AMALoginDataHandler::instance($dsn)->getLoginProviders($enabled, ' `displayOrder` ASC'); if (!AMA_DB::isError($res) && is_array($res) && count($res) > 0) { foreach ($res as $provider) { if ($getData === false) { $retArr[$provider[AMALoginDataHandler::$PREFIX . 'providers_id']] = $provider['className']; } else { $id = $provider[AMALoginDataHandler::$PREFIX . 'providers_id']; unset($provider[AMALoginDataHandler::$PREFIX . 'providers_id']); $retArr[$id] = $provider; } } return $retArr; } else { return null; } }
* Clear node and layout variable in $_SESSION */ $variableToClearAR = array('node', 'layout', 'course', 'user'); /** * Users (types) allowed to access this module. */ $allowedUsersAr = array(AMA_TYPE_SWITCHER); /** * Get needed objects */ $neededObjAr = array(AMA_TYPE_SWITCHER => array('layout')); /** * Performs basic controls before entering this module */ require_once ROOT_DIR . '/include/module_init.inc.php'; require_once ROOT_DIR . '/browsing/include/browsing_functions.inc.php'; // MODULE's OWN IMPORTS require_once dirname(__FILE__) . '/config/config.inc.php'; require_once MODULES_IMPEXPORT_PATH . '/include/exportHelper.class.inc.php'; /** * this is called async by the tree view to populate itself */ $courseID = isset($_GET['courseID']) && intval($_GET['courseID']) > 0 ? intval($_GET['courseID']) : 0; if ($courseID > 0) { $rootNode = $courseID . exportHelper::$courseSeparator . "0"; // need an Import/Export DataHandler $dh = AMAImpExportDataHandler::instance(MultiPort::getDSN($_SESSION['sess_selected_tester'])); $exportHelper = new exportHelper($courseID); $a = $exportHelper->getAllChildrenArray($rootNode, $dh); echo json_encode(array($a)); }
if ($id_tester !== FALSE) { $tester_infoAr = $common_dh->get_tester_info_from_id($id_tester); if (AMA_Common_DataHandler::isError($tester_infoAr)) { $errObj = new ADA_Error($tester_infoAr); } else { $testersAr = array(); $tester_dataAr = array(array(translateFN('id'), $tester_infoAr[0]), array(translateFN('Nome'), $tester_infoAr[1]), array(translateFN('Ragione Sociale'), $tester_infoAr[2]), array(translateFN('Indirizzo'), $tester_infoAr[3]), array(translateFN('Città'), $tester_infoAr[4]), array(translateFN('Provincia'), $tester_infoAr[5]), array(translateFN('Nazione'), $tester_infoAr[6]), array(translateFN('Telefono'), $tester_infoAr[7]), array(translateFN('E-mail'), $tester_infoAr[8]), array(translateFN('Descrizione'), $tester_infoAr[11]), array(translateFN('Responsabile'), $tester_infoAr[9]), array(translateFN('Puntatore al database'), $tester_infoAr[10])); //$tester_data = BaseHtmlLib::tableElement('',array(),$tester_dataAr); $tester_data = AdminModuleHtmlLib::displayTesterInfo($id_tester, $tester_dataAr); $services_dataAr = $common_dh->get_info_for_tester_services($id_tester); if (AMA_Common_DataHandler::isError($services_dataAr)) { $errObj = new ADA_Error($services_dataAr); } else { $tester_services = AdminModuleHtmlLib::displayServicesOnThisTester($id_tester, $services_dataAr); } $tester_dsn = MultiPort::getDSN($tester_infoAr[10]); if ($tester_dsn != NULL) { $tester_dh = AMA_DataHandler::instance($tester_dsn); $users_on_this_tester = $tester_dh->count_users_by_type(array(AMA_TYPE_STUDENT, AMA_TYPE_AUTHOR, AMA_TYPE_TUTOR, AMA_TYPE_SWITCHER, AMA_TYPE_ADMIN)); if (AMA_DataHandler::isError($users_on_this_tester)) { $errObj = new ADA_Error($users_on_this_tester); } else { $users_list_link = CDOMElement::create('div', 'id:tester_users'); $users_list_link->addChild(new CText(translateFN('Numero di utenti presenti sul tester: ') . $users_on_this_tester)); $link = CDOMElement::create('a', 'href:list_users.php?id_tester=' . $id_tester); $link->addChild(new CText(translateFN('Lista utenti'))); $users_list_link->addChild($link); } } } } else {
/** * sets student datas into the student table in the proper tester. * Do no call parent function here, since we do not want to save * standard user (student) data (they're personal data and are saved separately) * * NOTE: * This is usally called by the save_*.php file in the ajax directory * via a call to the MultiPort. * * @param number id_student id of the student whose datas are to be updated * @param array datas to be saved * * @return id of saved student on success, AMA_Error on ErrorException * @access public * * @see AMA_Tester_DataHandler::set_student() */ public function set_student($id_student, $user_dataAr, $extraTableName = false, $userObj = null, &$idFromPublicTester = null) { $db =& $this->getConnection(); if (AMA_DB::isError($db)) { return $db; } /* * if we're not saving extra fields, just call the parent * BUT: if we're saving extra fields, we do not call the parent because we want * extra fields to be saved by themselves!! */ // $retval = false; // if (!$extraTableName) $retval = parent::set_student($id_student, $user_dataAr); $retval = parent::set_student($id_student, $user_dataAr); if ($extraTableName) { if ($extraTableName == ADAUser::getExtraTableName()) { // aka Extra, stored in ADAUser::getExtraTableKeyProperty() table // usually is the 'studente' table $user_id_sql = 'SELECT ' . ADAUser::getExtraTableKeyProperty() . ' FROM ' . $extraTableName . ' WHERE ' . ADAUser::getExtraTableKeyProperty() . '=?'; $user_id = $this->getOnePrepared($user_id_sql, array($id_student)); // if it's an error return it right away if (AMA_DB::isError($user_id)) { $retval = $user_id; } else { // get ExtraFields array $extraFields = $userObj->getExtraFields(); if (!AMA_DB::isError($extraFields) && is_array($extraFields) && count($extraFields) > 0) { // if $user_id not found, build an insert into else an update if ($user_id === false) { $saveQry = "INSERT INTO " . $extraTableName . " ( " . ADAUser::getExtraTableKeyProperty() . ", "; $saveQry .= implode(", ", $extraFields); $saveQry .= ") VALUES (" . $id_student . str_repeat(",?", count($extraFields)) . ")"; } else { $saveQry = "UPDATE " . $extraTableName . " SET "; foreach ($extraFields as $num => $field) { $saveQry .= $field . "=?"; if ($num < count($extraFields) - 1) { $saveQry .= ", "; } } $saveQry .= " WHERE " . ADAUser::getExtraTableKeyProperty() . "=" . $id_student; } // build valuesAr with extraFields only foreach ($extraFields as $field) { if (isset($user_dataAr[$field])) { // check if it's a date and convert it to timestamp if (stripos($field, "date") !== false) { $valuesAr[] = $this->date_to_ts($user_dataAr[$field]); } else { $valuesAr[] = $user_dataAr[$field]; } } else { $valuesAr[] = null; } } $result = $this->queryPrepared($saveQry, $valuesAr); if (AMA_DB::isError($result)) { $retval = $result; } else { $retval = true; } } } } else { if (in_array($extraTableName, ADAUser::getLinkedTables())) { // stored in tableprefix_$extraTableName $uniqueField = $extraTableName::getKeyProperty(); $tblPrefix = ADAUser::getTablesPrefix(); $fieldList = $extraTableName::getFields(); // search for the unique field int the fieldList array $pos = array_search($uniqueField, $fieldList, true); // if found unset it since it doesn't need to be saved if ($pos !== false) { unset($fieldList[$pos]); } $rowsToSave = $user_dataAr[$extraTableName]; foreach ($rowsToSave as $rowToSave) { // if row element is not to be saved, continue to next element if ($rowToSave['_isSaved'] == 1) { continue; } if ($rowToSave[$uniqueField] > 0) { $saveQry = "UPDATE " . $tblPrefix . $extraTableName . " SET "; foreach ($fieldList as $num => $field) { $saveQry .= $field . "=?"; if ($num < count($fieldList)) { $saveQry .= ", "; } } $saveQry .= " WHERE " . $uniqueField . "=" . $rowToSave[$uniqueField]; $nextID = $rowToSave[$uniqueField]; } else { // if using the public tester and the idFromPublicTester is not set or lt 0 if (MultiPort::getDSN(ADA_PUBLIC_TESTER) === $this->dsn && intval($idFromPublicTester) <= 0) { // retrieve the id for the next insert $nextIDQry = "SELECT MAX(" . $uniqueField . ") FROM " . $tblPrefix . $extraTableName; $nextID = $db->getOne($nextIDQry); $nextID = is_null($nextID) ? 1 : ++$nextID; $idFromPublicTester = $nextID; } else { $nextID = $idFromPublicTester; } $saveQry = "INSERT INTO " . $tblPrefix . $extraTableName . "( " . $uniqueField . ", "; $saveQry .= implode(", ", $fieldList) . " ) VALUES ( " . $nextID; $saveQry .= str_repeat(" ,?", count($fieldList)) . " )"; } unset($rowToSave[$uniqueField]); // prepare the array to be passed to the query $valuesArr = array(); foreach ($fieldList as $field) { if (isset($rowToSave[$field])) { // check if it's a date and convert it to timestamp if (stripos($field, "date") !== false) { $valuesArr[] = $this->date_to_ts($rowToSave[$field]); } else { $valuesArr[] = $rowToSave[$field]; } } else { $valuesArr[] = null; } } $result = $this->queryPrepared($saveQry, $valuesArr); if (AMA_DB::isError($result)) { $retval = $result; } else { if (is_null($nextID) || intval($nextID) === 0) { /** * If could not geta nextID from the ADA_PUBLIC_TESTER * read it as the lastInsertID and set it as the $idFromPublicTester */ $nextID = $this->getConnection()->lastInsertID(); if (is_null($idFromPublicTester) || intval($idFromPublicTester) === 0) { $idFromPublicTester = $nextID; } } $retval = $nextID; } } } } } return $retval; // return insertedId on success, else the erorr }
/** * calls and sets the parent instance method, and if !MULTIPROVIDER * checks if module_login_providers table is in the provider db. * * If found, use the provider DB else use the common * * @param string $dsn */ static function instance($dsn = null) { if (!MULTIPROVIDER && is_null($dsn)) { $dsn = MultiPort::getDSN($GLOBALS['user_provider']); } $theInstance = parent::instance($dsn); if (is_null(self::$dbToUse)) { self::$dbToUse = AMA_Common_DataHandler::instance(); if (!MULTIPROVIDER && !is_null($dsn)) { // must check if passed $dsn has the module login tables // execute this dummy query, if result is not an error table is there $sql = 'SELECT NULL FROM `' . self::$PREFIX . 'providers`'; // must use AMA_DataHandler because we are not able to // query AMALoginDataHandelr in this method! $ok = AMA_DataHandler::instance($dsn)->getOnePrepared($sql); if (!AMA_DB::isError($ok)) { self::$dbToUse = $theInstance; } } } return $theInstance; }
$private_chatrooms_ar = ChatRoom::get_all_private_chatroomsFN($sess_id_user); if (is_array($private_chatrooms_ar)) { $all_chatrooms_ar = array_merge($chatrooms_class_ids_ar, $private_chatrooms_ar); } else { $all_chatrooms_ar = $chatrooms_class_ids_ar; } // sort the chatrooms in reverse order, so we can visualize first the most recent chatrooms rsort($all_chatrooms_ar); //initialize the array of the chatrooms to be displayed on the screen $list_chatrooms = array(); // start the construction of the table contaning all the chatrooms $tbody_data[] = array(); foreach ($all_chatrooms_ar as $id_chatroom) { //initialize a chatroom Object if (!is_object($id_chatroom)) { $chatroomObj = new ChatRoom($id_chatroom, MultiPort::getDSN($sess_selected_tester)); //get the array with all the current info of the chatoorm $chatroom_ha = $chatroomObj->get_info_chatroomFN($id_chatroom); $id_course_instance = $chatroom_ha['id_istanza_corso']; $id_course = $dh->get_course_id_for_course_instance($chatroom_ha['id_istanza_corso']); $courseObj = read_course($id_course); if (is_object($courseObj) && !AMA_dataHandler::isError($userObj)) { $course_title = $courseObj->titolo; //title $id_toc = $courseObj->id_nodo_toc; //id_toc_node } // get the owner of the room $chat_title = $chatroom_ha['titolo_chat']; // get the type of the chatroom $c_type = $chatroom_ha['tipo_chat'];
require_once ROOT_DIR . '/include/module_init.inc.php'; $self = whoami(); require_once 'include/browsing_functions.inc.php'; $courseInstances = array(); $serviceProviders = $userObj->getTesters(); /** * change the two below call to active to let the closed * instances completely disappear from the HTML table */ if (count($serviceProviders) == 1) { $provider_dh = AMA_DataHandler::instance(MultiPort::getDSN($serviceProviders[0])); // $courseInstances = $provider_dh->get_course_instances_active_for_this_student($userObj->getId()); $courseInstances = $provider_dh->get_course_instances_for_this_student($userObj->getId(), true); } else { foreach ($serviceProviders as $Provider) { $provider_dh = AMA_DataHandler::instance(MultiPort::getDSN($Provider)); // $courseInstances_provider = $provider_dh->get_course_instances_active_for_this_student($userObj->getId()); $courseInstances_provider = $provider_dh->get_course_instances_for_this_student($userObj->getId(), true); $courseInstances = array_merge($courseInstances, $courseInstances_provider); } } if (!AMA_DataHandler::isError($courseInstances)) { /** * @author giorgio 23/apr/2015 * * filter course instance that are associated to a level of service having nonzero * value in isPublic, so that all instances of public courses will not be shown here */ $courseInstances = array_filter($courseInstances, function ($courseInstance) { if (is_null($courseInstance['tipo_servizio'])) { $courseInstance['tipo_servizio'] = DEFAULT_SERVICE_TYPE;
/** * * @param $id_course_instance * @return array */ private function _get_last_accessFN($id_course_instance = "", $provider_dh, $return_dateonly = true) { // if used by student before entering a course, we must pass the DataHandler if ($provider_dh == NULL) { $provider_dh = $GLOBALS['dh']; } //$error = $GLOBALS['error']; // $debug = $GLOBALS['debug']; $sess_id_user = $_SESSION['sess_id_user']; if (!isset($this->id_user)) { $id_user = $sess_id_user; } else { $id_user = $this->id_user; } if ($id_course_instance) { $last_visited_node = $provider_dh->get_last_visited_nodes($id_user, $id_course_instance, 10); /* * vito, 10 ottobre 2008: $last_visited_node è Array([0]=>Array([id_nodo], ...)) */ if (!AMA_DB::isError($last_visited_node) && is_array($last_visited_node) && isset($last_visited_node[0])) { $last_visited_time = $return_dateonly ? AMA_DataHandler::ts_to_date($last_visited_node[0]['data_uscita']) : $last_visited_node[0]['data_uscita']; return array($last_visited_node[0]['id_nodo'], $last_visited_time); } else { return "-"; } } else { /* * Sara, 2/07/2014 * return the last access between all instances course */ $serviceProviders = $this->getTesters(); if (!empty($serviceProviders) && is_array($serviceProviders)) { $i = 0; foreach ($serviceProviders as $Provider) { $provider_dh = AMA_DataHandler::instance(MultiPort::getDSN($Provider)); $courseInstances_provider = $provider_dh->get_course_instances_for_this_student($this->getId()); if (AMA_DataHandler::isError($courseInstances_provider)) { $courseInstances_provider = new ADA_Error($courseInstances_provider); } else { $istance_testerAr[$i] = array('istances' => $courseInstances_provider, 'provider' => $Provider); } $i++; } } if (!empty($istance_testerAr)) { $Max = 0; $id_nodo = null; foreach ($istance_testerAr as $istanceTs) { $courseInstancesAr = $istanceTs['istances']; $pointer = $istanceTs['provider']; $tester = AMA_DataHandler::instance(MultiPort::getDSN($pointer)); foreach ($courseInstancesAr as $courseInstance) { $id_instance = $courseInstance['id_istanza_corso']; $last_access = $tester->get_last_visited_nodes($id_user, $id_instance, 10); if (!AMA_DB::isError($last_access) && is_array($last_access) && count($last_access)) { $last_accessAr = array($last_access[0]['id_nodo'], $last_access[0]['data_uscita']); if ($last_accessAr[1] > $Max) { $id_nodo = $last_accessAr[0]; $Max = $last_accessAr[1]; } } } } $Last_accessAr = array(0 => $id_nodo, 1 => $Max); return $Last_accessAr; } else { return "-"; } } }
/* * 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;
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; } }
* INCLUSIONE SPECIFICA PER PAYPAL */ if (file_exists(ROOT_DIR . '/browsing/paypal/paypal_conf.inc.php')) { require_once ROOT_DIR . '/browsing/paypal/paypal_conf.inc.php'; $paypal_allowed = TRUE; } $today_date = today_dateFN(); $providerId = DataValidator::is_uinteger($_GET['provider']); $courseId = DataValidator::is_uinteger($_GET['course']); $instanceId = DataValidator::is_uinteger($_GET['instance']); $studentId = DataValidator::is_uinteger($_GET['student']); $testerInfoAr = $common_dh->get_tester_info_from_id($providerId, 'AMA_FETCH_ASSOC'); if (!AMA_Common_DataHandler::isError($testerInfoAr)) { $provider_name = $testerInfoAr[1]; $tester = $testerInfoAr[10]; $tester_dh = AMA_DataHandler::instance(MultiPort::getDSN($tester)); $currentTesterId = $newTesterId; $GLOBALS['dh'] = $tester_dh; $dh = $tester_dh; /* * GESTIONE LOG */ $logStr = ""; $log_file = ROOT_DIR . '/browsing/paypal/' . PAYPAL_IPN_LOG; $logFd = fopen($log_file, "a"); $fpx = fopen($log_file, 'a'); $debug = 1; if ($debug == 1) { fwrite($fpx, "INIZIO processo Confirm \n"); fwrite($fpx, "Student: {$studentId} \n"); }
*/ 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); }