public static function findTokenForPasswordChange($user_id, $token) { $common_dh = $GLOBALS['common_dh']; $token_dataAr = $common_dh->get_token($token, $user_id, ADA_TOKEN_FOR_PASSWORD_CHANGE); if (AMA_Common_DataHandler::isError($token_dataAr)) { return false; } $tokenObj = new ChangePasswordToken(); $tokenObj->fromArray($token_dataAr); return $tokenObj; }
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; }
* 1. dati del tester (con link modifica) * 2. elenco servizi erogati dal tester (con link modifica) * 3. link a lista utenti presenti sul tester */ $id_tester = DataValidator::is_uinteger($_GET['id_tester']); 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')));
public function get_admin($id) { // get a row from table UTENTE $get_user_result = $this->_get_user_info($id); if (AMA_Common_DataHandler::isError($get_user_result)) { // $get_user_result is an AMA_Error object //? } return $get_user_result; }
$service_dataAr['service_name'] = $course['nome']; $service_dataAr['service_description'] = $course['descr']; $service_dataAr['service_level'] = 99; $service_dataAr['service_duration'] = 9999; $service_dataAr['service_min_meetings'] = 1; $service_dataAr['service_max_meetings'] = 999; $service_dataAr['service_meeting_duration'] = 7200; $service_id = $common_dh->add_service($service_dataAr); if (AMA_Common_DataHandler::isError($service_id)) { $service_id = NULL; $msg .= ' Aggiunta servizio non riuscita'; } else { $selected_tester = $_SESSION['sess_selected_tester']; $testerId = $GLOBALS['testers_dataAr'][$selected_tester]; $link_service = $common_dh->link_service_to_course($testerId, $service_id, $course_id); if (AMA_Common_DataHandler::isError($link_service)) { $msg .= ' Associazione servizio non riuscita'; } } /* * Il corso e' stato creato correttamente, redirezioniamo * l'utente allla vista del nodo principale del corso * appena creato. */ $root_node_id = $course_id . '_0'; $redirect_to = $http_root_dir . '/browsing/view.php?id_course=' . $course_id . '&id_node=' . $root_node_id; header("Location: {$redirect_to}"); exit; } } }
require_once ROOT_DIR . '/include/module_init.inc.php'; $self = whoami(); // = admin! include_once 'include/admin_functions.inc.php'; /* * YOUR CODE HERE */ /* * 1. dati del tester (con link modifica) * 2. elenco servizi erogati dal tester (con link modifica) * 3. link a lista utenti presenti sul tester */ $id_tester = DataValidator::is_uinteger($_GET['id_tester']); 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('Provincia') , $tester_infoAr[4]), array(translateFN('Città') , $tester_infoAr[5]), array(translateFN('Nazione') , $tester_infoAr[6]), array(translateFN('Telefono') , $tester_infoAr[7]), array(translateFN('E-mail') , $tester_infoAr[8]), array(translateFN('Responsabile') , $tester_infoAr[9]), array(translateFN('Puntatore al database') , $tester_infoAr[10])
$userTesterInfo = $common_dh->get_tester_info_from_pointer($user_provider_name); $user_provider_id = !AMA_DB::isError($userTesterInfo) ? $userTesterInfo[0] : null; $redirect = is_null($user_provider_id); } else { $redirect = true; } if (!$redirect) { $publishedServices = $common_dh->get_published_courses($user_provider_id); } else { header('Location: ' . HTTP_ROOT_DIR . '/info.php'); die; } } else { $publishedServices = $common_dh->get_published_courses(); } if (!AMA_Common_DataHandler::isError($publishedServices)) { // $thead_data = array('nome', 'descrizione', 'durata (giorni)', 'informazioni'); $thead_data = array(translateFN('nome'), translateFN('descrizione'), translateFN('crediti'), translateFN('informazioni')); $tbody_data = array(); foreach ($publishedServices as $service) { $serviceId = $service['id_servizio']; $coursesAr = $common_dh->get_courses_for_service($serviceId); if (!AMA_DB::isError($coursesAr)) { $currentTesterId = 0; $currentTester = ''; $tester_dh = null; foreach ($coursesAr as $courseData) { $courseId = $courseData['id_corso']; $Flag_course_has_instance = false; $newTesterId = $courseData['id_tester']; if ($newTesterId != $currentTesterId) {
} else { // first time here $case = 1; $op = "insert_username"; } if (isset($_GET['status'])) { $status = $_GET['status']; } else { $status = translateFN("New password"); } switch ($op) { case "check_username": $username = $_POST['username']; if ($username != NULL) { $user_id = $common_dh->find_user_from_username($username); if (AMA_Common_DataHandler::isError($user_id)) { // Utente non esistente o non loggable /* * Verifico se esiste un utente che ha come email il contenuto del * campo $username */ // $user_id = $common_dh->find_user_from_email($username); // if(AMA_Common_DataHandler::isError($user_id)) { $message = translateFN("Username is not valid"); $redirect_to = HTTP_ROOT_DIR . "/browsing/forget.php?message={$message}"; header('Location:' . $redirect_to); exit; // } } $userObj = MultiPort::findUser($user_id); //read_user($user_id); // ?
function parameter_controlFN($neededObjAr = array(), $allowedUsersAr = array()) { $invalid_session = FALSE; $invalid_user = FALSE; $invalid_node = FALSE; $invalid_course = FALSE; $invalid_course_instance = FALSE; $invalid_user_level = FALSE; $guest_user_not_allowed = FALSE; /* * ADA common data handler */ $common_dh = isset($GLOBALS['common_dh']) ? $GLOBALS['common_dh'] : null; if (!$common_dh instanceof AMA_Common_DataHandler) { $common_dh = AMA_Common_DataHandler::instance(); $GLOBALS['common_dh'] = $common_dh; } /* * User object: always load a user */ $sess_id_user = isset($_SESSION['sess_id_user']) ? (int) $_SESSION['sess_id_user'] : 0; $sess_userObj = read_user($sess_id_user); if (ADA_Error::isError($sess_userObj)) { $sess_userObj->handleError(); } $_SESSION['sess_id_user'] = $sess_id_user; if ($sess_userObj instanceof ADAGenericUser) { $_SESSION['sess_userObj'] = $sess_userObj; /* * Check if this user is allowed to access the current module */ if (!in_array($sess_userObj->getType(), $allowedUsersAr)) { header('Location: ' . $sess_userObj->getHomePage()); exit; } } else { unset($_SESSION['sess_userObj']); $invalid_user = TRUE; } $id_profile = $sess_userObj->getType(); /* * Get needed object for this user from $neededObjAr */ if (is_array($neededObjAr) && isset($neededObjAr[$id_profile]) && is_array($neededObjAr[$id_profile])) { $thisUserNeededObjAr = $neededObjAr[$id_profile]; } else { $thisUserNeededObjAr = array(); } /* * * 'default_tester' AL MOMENTO VIENE RICHIESTO SOLO DA USER.php * QUI ABBIAMO NECESSITA' DI CANCELLARE LA VARIABILE DI SESSIONE * sess_id_course. * Gia' che ci siamo facciamo unset anche di sess_id_node * e di sess_id_course_instance * * Tester selection: * * se ho richiesto la connessione al database del tester di default, * controllo che il tipo di utente sia ADAUser (al momento e' l'unico ad * avere questa necessita'). * * se non ho richiesto la connessione al tester di default, allora verifico * se l'utente e' di tipo ADAUser, e ottengo la connessione al database * tester appropriato. */ if (in_array('default_tester', $thisUserNeededObjAr) && $id_profile == AMA_TYPE_STUDENT) { $_SESSION['sess_selected_tester'] = NULL; unset($_SESSION['sess_id_course']); unset($_SESSION['sess_id_course_instance']); unset($_SESSION['sess_id_node']); } else { if ($id_profile == AMA_TYPE_STUDENT) { if (isset($_REQUEST['id_course'])) { $id_course = DataValidator::is_uinteger($_REQUEST['id_course']); } else { $id_course = false; } if (isset($_SESSION['sess_id_course'])) { $sess_id_course = DataValidator::is_uinteger($_SESSION['sess_id_course']); } else { $sess_id_course = false; } if (isset($_REQUEST['id_node'])) { $req_id_node = DataValidator::validate_node_id($_REQUEST['id_node']); } else { $req_id_node = false; } if ($id_course === FALSE && $sess_id_course === FALSE && $req_id_node !== FALSE) { $id_course = substr($req_id_node, 0, strpos($req_id_node, '_')); } if ($id_course !== FALSE && $id_course !== $sess_id_course) { $tester_infoAr = $common_dh->get_tester_info_from_id_course($id_course); if (AMA_Common_DataHandler::isError($tester_infoAr)) { $selected_tester = NULL; } else { $selected_tester = $tester_infoAr['puntatore']; } $_SESSION['sess_selected_tester'] = $selected_tester; } } } /* * ADA tester data handler * Data validation on $sess_selected_tester is performed by MultiPort::getDSN() */ /** * giorgio 12/ago/2013 * set selected tester if it's not a multiprovider environment */ if (!MULTIPROVIDER && isset($GLOBALS['user_provider'])) { $sess_selected_tester = $GLOBALS['user_provider']; } else { $sess_selected_tester = isset($_SESSION['sess_selected_tester']) ? $_SESSION['sess_selected_tester'] : null; } //$dh = AMA_DataHandler::instance(MultiPort::getDSN($sess_selected_tester)); $sess_selected_tester_dsn = MultiPort::getDSN($sess_selected_tester); $_SESSION['sess_selected_tester_dsn'] = $sess_selected_tester_dsn; $dh = new AMA_DataHandler($sess_selected_tester_dsn); $GLOBALS['dh'] = $dh; if (empty($GLOBALS['sess_id'])) { $invalid_session = TRUE; } /* * Node object */ // TODO: portare in sessione $nodeObj? if (in_array('node', $thisUserNeededObjAr)) { $id_node = isset($_REQUEST['id_node']) ? DataValidator::validate_node_id($_REQUEST['id_node']) : false; $sess_id_node = isset($_SESSION['sess_id_node']) ? DataValidator::validate_node_id($_SESSION['sess_id_node']) : false; if ($id_node !== FALSE) { $dataHa = $dh->get_node_info($id_node); if (AMA_DataHandler::isError($dataHa) || !is_array($dataHa)) { $invalid_node = TRUE; } else { $_SESSION['sess_id_node'] = $id_node; } } elseif ($sess_id_node !== FALSE) { $dataHa = $dh->get_node_info($sess_id_node); if (AMA_DataHandler::isError($dataHa) || !is_array($dataHa)) { $invalid_node = TRUE; } else { $_SESSION['sess_id_node'] = $sess_id_node; } } else { $invalid_node = TRUE; } /** * @author giorgio 18/mag/2015 * * Could be that a non-student has request a node from * the default tester in a multiprovider environment * Check this before giving up an marking the node as invalid */ if (MULTIPROVIDER && $id_profile != AMA_TYPE_STUDENT && $invalid_node === true && $id_node !== false) { $invalid_node = checkAndSetPublicTester('node', $id_node); } } /* * Course object */ if (in_array('course', $thisUserNeededObjAr)) { $id_course = isset($_REQUEST['id_course']) ? DataValidator::is_uinteger($_REQUEST['id_course']) : false; $sess_id_course = isset($_SESSION['sess_id_course']) ? DataValidator::is_uinteger($_SESSION['sess_id_course']) : false; /* extracting the course id from node id, if given */ if (isset($_SESSION['sess_id_node']) && !$invalid_node && $id_course === false) { // if ($nodeObj instanceof Node){ $courseIdFromNodeId = substr($_SESSION['sess_id_node'], 0, strpos($_SESSION['sess_id_node'], '_')); $sess_courseObj = read_course($courseIdFromNodeId); if (ADA_Error::isError($sess_courseObj)) { unset($_SESSION['sess_courseObj']); $invalid_course = TRUE; } else { if ($sess_userObj instanceof ADAGuest && !$sess_courseObj->getIsPublic()) { unset($_SESSION['sess_courseObj']); $invalid_course = TRUE; } else { $_SESSION['sess_courseObj'] = $sess_courseObj; $_SESSION['sess_id_course'] = $courseIdFromNodeId; } } } elseif ($id_course !== FALSE) { $sess_courseObj = read_course($id_course); if (ADA_Error::isError($sess_courseObj)) { unset($_SESSION['sess_courseObj']); $invalid_course = TRUE; } else { if ($sess_userObj instanceof ADAGuest && !$sess_courseObj->getIsPublic()) { unset($_SESSION['sess_courseObj']); $invalid_course = TRUE; } else { $_SESSION['sess_courseObj'] = $sess_courseObj; $_SESSION['sess_id_course'] = $id_course; } } } elseif ($sess_id_course !== FALSE) { $sess_courseObj = read_course($sess_id_course); if (ADA_Error::isError($sess_courseObj)) { unset($_SESSION['sess_courseObj']); $invalid_course = TRUE; } else { if ($sess_userObj instanceof ADAGuest && !$sess_courseObj->getIsPublic()) { unset($_SESSION['sess_courseObj']); $invalid_course = TRUE; } else { $_SESSION['sess_courseObj'] = $sess_courseObj; $_SESSION['sess_id_course'] = $sess_courseObj->getId(); } } } else { unset($_SESSION['sess_courseObj']); $invalid_course = TRUE; } /** * @author giorgio 18/mag/2015 * * Could be that a non-student has request a course from * the default tester in a multiprovider environment * Check this before giving up an marking the course as invalid */ if (MULTIPROVIDER && $id_profile != AMA_TYPE_STUDENT && $invalid_course === true && ($id_course !== false || $sess_id_course !== false)) { $invalid_course = checkAndSetPublicTester('course', $id_course !== false ? $id_course : $sess_id_course); if ($invalid_course === false) { $invalid_node = false; $sess_courseObj = $_SESSION['sess_courseObj']; // SESSION set by checkAndSetPublicTester } } } else { unset($_SESSION['sess_courseObj']); } /** * If in a valid NON PUBLIC course and user is student or tutor * and * $_SESSION['sess_id_course'] (that is the course_id the user is going into) * IS NOT EQUAL TO * $sess_id_course (that is the course_id the user is coming form) * * The user has clicked a cross course link, and is handled by unsetting the * $_SESSION['sess_id_course_instance'] and looking for a course instance * to which the user is subscribed. * */ if ($invalid_course === FALSE && $invalid_node === FALSE && isset($sess_courseObj) && !$sess_courseObj->getIsPublic() && in_array($sess_userObj->getType(), array(AMA_TYPE_STUDENT, AMA_TYPE_TUTOR)) && is_numeric($sess_id_course) && intval($_SESSION['sess_id_course']) !== intval($sess_id_course)) { /** * unset sess_id_course_instance */ unset($_SESSION['sess_id_course_instance']); /** * Try to find an instance of target course where used is subscribed */ $getAll = true; /** * Need to get instance the user is allowed to browse, based on user type */ switch ($sess_userObj->getType()) { case AMA_TYPE_STUDENT: $instances = $dh->get_course_instance_for_this_student_and_course_model($sess_userObj->getId(), $_SESSION['sess_id_course'], $getAll); break; case AMA_TYPE_TUTOR: $instances = $dh->get_course_instance_for_this_student_and_course_model($sess_userObj->getId(), $_SESSION['sess_id_course'], $getAll); if (AMA_DB::isError($instances) || !is_array($instances) || count($instances) <= 0) { $instances = array(); } $tutorInstances = $dh->get_tutors_assigned_course_instance($sess_userObj->getId(), $_SESSION['sess_id_course'], $sess_userObj->isSuper()); if (!AMA_DB::isError($tutorInstances) && is_array($tutorInstances) && count($tutorInstances) > 0) { /** * the returned array is array[id_tutor]=>array[key]=>array['id_istanza_corso'] * and needs to be converted to reflect the structre returned in student case */ foreach ($tutorInstances[$sess_userObj->getId()] as $tutorInstance) { $instances[]['id_istanza_corso'] = $tutorInstance['id_istanza_corso']; } } break; } if (!AMA_DB::isError($instances) && count($instances) > 0) { if (count($instances) == 1) { /** * User is subscribed to one instance only, good! * Set the $target_course_instance var and proceed */ $target_course_instance = $instances[0]['id_istanza_corso']; } else { if (count($instances) > 1 && !isset($_REQUEST['id_course_instance'])) { /** * If there's more than one instance, must build an array of * found instances to ask the user to select one. * * This array is returned in the 'course' key of the returned * array and so $invalid_course must be populated accordingly. * * The node that was requested is returned in the 'node' key of * the returned array and so $invalid_node must be populated. */ foreach ($instances as $instance) { $invalid_course[] = $instance['id_istanza_corso']; $invalid_node = $_SESSION['sess_id_node']; } } else { if (isset($_REQUEST['id_course_instance'])) { $target_course_instance = $_REQUEST['id_course_instance']; } } } } else { /** * Mark the course as invalid, and unset session var */ $invalid_course = TRUE; unset($_SESSION['sess_id_course']); } } /* * Course_instance object */ if (in_array('course_instance', $thisUserNeededObjAr)) { /* * Se ci troviamo nel tester pubblico, allora non dobbiamo leggere un'istanza corso * dato che non ce ne sono. */ if (!$invalid_course && !$sess_courseObj->getIsPublic()) { if (isset($target_course_instance)) { $id_course_instance = DataValidator::is_uinteger($target_course_instance); } else { if (isset($_REQUEST['id_course_instance'])) { $id_course_instance = DataValidator::is_uinteger($_REQUEST['id_course_instance']); // FIXME: qui ci va $_REQUEST['id_course_instance'] } else { $id_course_instance = false; } } $sess_id_course_instance = isset($_SESSION['sess_id_course_instance']) ? DataValidator::is_uinteger($_SESSION['sess_id_course_instance']) : false; if ($id_course_instance !== FALSE) { $course_instanceObj = read_course_instance_from_DB($id_course_instance); if (ADA_Error::isError($course_instanceObj)) { $invalid_course_instance = TRUE; } else { $UserType = $sess_userObj->getType(); switch ($sess_userObj->getType()) { case AMA_TYPE_STUDENT: $studentLevel = $dh->_get_student_level($sess_id_user, $id_course_instance); if (AMA_DataHandler::isError($studentLevel)) { $invalid_course_instance = TRUE; } break; case AMA_TYPE_TUTOR: if (!$sess_userObj->isSuper() && $course_instanceObj->getServiceLevel() != ADA_SERVICE_TUTORCOMMUNITY) { $tutorsInstance = $dh->course_instance_tutor_get($id_course_instance, $number = 2); if (AMA_DataHandler::isError($tutorsInstance)) { $invalid_course_instance = TRUE; } elseif (!in_array($sess_id_user, $tutorsInstance)) { $invalid_course_instance = TRUE; } } break; default: // $invalid_course_instance = TRUE; break; } if (!$invalid_course_instance) { $_SESSION['sess_id_course_instance'] = $id_course_instance; $sess_id_course_instance = $_SESSION['sess_id_course_instance']; } } } elseif ($sess_id_course_instance !== FALSE) { $instanceIdRequired = array(); if (isset($_SESSION['sess_id_node']) && !$invalid_node) { // if ($nodeObj instanceof Node) { // required a node $instanceIdRequired[] = isset($dataHa['instance']) ? $dataHa['instance'] : null; if ($instanceIdRequired[0] == 0) { // the node is NOT a note $field_list_ar = array(); if (isset($_SESSION['sess_id_course']) && !$invalid_course) { $courseIdRequired = $_SESSION['sess_id_course']; $InstanceIdList = $dh->course_instance_get_list($field_list_ar, $courseIdRequired); if (AMA_DataHandler::isError($InstanceIdList) || count($InstanceIdList) == 0) { $invalid_course_instance = TRUE; } } else { $invalid_course_instance = TRUE; } $instanceIdRequired = array(); foreach ($InstanceIdList as $InstanceId) { array_push($instanceIdRequired, $InstanceId[0]); } } // end if NOTE } elseif ($sess_courseObj instanceof Course) { $courseIdRequired = $sess_courseObj->id; $InstanceIdList = $dh->course_instance_get_list(array(), $courseIdRequired); if (AMA_DataHandler::isError($InstanceIdList) || count($InstanceIdList) == 0) { $invalid_course_instance = TRUE; } $instanceIdRequired = array(); foreach ($InstanceIdList as $InstanceId) { array_push($instanceIdRequired, $InstanceId[0]); } } // var_dump($instanceIdRequired,$sess_id_course_instance); $UserType = $sess_userObj->getType(); switch ($UserType) { case AMA_TYPE_STUDENT: case AMA_TYPE_TUTOR: if (!in_array($sess_id_course_instance, $instanceIdRequired)) { $invalid_course_instance = TRUE; } break; case AMA_TYPE_SWITCHER: case AMA_TYPE_AUTHOR: default: break; } //end switch UserType $course_instanceObj = read_course_instance_from_DB($sess_id_course_instance); if (ADA_Error::isError($course_instanceObj)) { $course_instanceObj->handleError(); } $_SESSION['sess_id_course_instance'] = $sess_id_course_instance; } else { $invalid_course_instance = TRUE; } } //end isUserBrowsingThePublicTester } // end if in_array /* * Check if current user is a ADAGuest user and that he/she has requested * a public course instance. */ // // if(in_array('user', $neededObjAr[$user_type]) && in_array('course_instance', $neededObjAr[$user_type])) { // if(!$invalid_user && $sess_userObj instanceof ADAGuest) { // if ($invalid_course_instance || $course_instanceObj->status != ADA_COURSEINSTANCE_STATUS_PUBLIC) { // $guest_user_not_allowed = TRUE; // } // } // } // TODO: controllo livello utente /* * controllare che sia settato $sess_user_level e che il valore sia tra 0 e * ADA_MAX_USER_LEVEL */ $parm_errorHa = array('session' => $invalid_session, 'user' => $invalid_user, 'user_level' => $invalid_user_level, 'course' => $invalid_course, 'course_instance' => $invalid_course_instance, 'node' => $invalid_node, 'guest_user_not_allowed' => $guest_user_not_allowed); return $parm_errorHa; }
$stop = count($filenameAr) - 1; $course_instance = isset($filenameAr[0]) ? $filenameAr[0] : null; $id_sender = isset($filenameAr[1]) ? $filenameAr[1] : null; $id_course = isset($filenameAr[2]) ? $filenameAr[2] : null; if ($course_instance == $sess_id_course_instance && $id_course == $sess_id_course) { if (is_numeric($id_sender)) { $id_node = $filenameAr[2] . "_" . $filenameAr[3]; $filename = ''; for ($k = 5; $k <= $stop; $k++) { $filename .= $filenameAr[$k]; if ($k < $stop) { $filename .= "_"; } } $sender_array = $common_dh->get_user_info($id_sender); if (!AMA_Common_DataHandler::isError($sender_array)) { $id_profile = $sender_array['tipo']; switch ($id_profile) { case AMA_TYPE_STUDENT: case AMA_TYPE_AUTHOR: case AMA_TYPE_TUTOR: $user_name_sender = $sender_array['username']; $user_surname_sender = $sender_array['cognome']; $user_name_sender = $sender_array['nome']; $user_name_complete_sender = $user_name_sender . ' ' . $user_surname_sender; /** * @todo verificare a cosa serve $fid_node. Apparentemente non usato */ if (!isset($fid_node) or $fid_node == $id_node) { $out_fields_ar = array('nome'); $clause = "ID_NODO = '{$id_node}'";
/** * gets new nodes array for given courseinstance and user * directly called by user class constructor to get all new nodes to be put in the sess_userObj object. * * @param ADALoggableUser $userObj user to get new nodes array for * * @return array contains id_nodo, id_istanza and titolo of the new nodes * * @access public * * @author giorgio 29/apr/2013 */ public static function get_new_nodes($userObj) { if ($userObj instanceof ADAGuest) { return 0; } $common_dh = $GLOBALS['common_dh']; $testers_activity_dataAr = array(); $testers_infoAr = $common_dh->get_all_testers(array('id_tester', 'nome')); if (AMA_Common_DataHandler::isError($testers_infoAr)) { return array(); } $userId = $userObj->getId(); $result = array(); foreach ($testers_infoAr as $tester_infoAr) { if (!isset($result[$tester_infoAr['puntatore']])) { $result[$tester_infoAr['puntatore']] = array(); } $tester_dsn = self::getDSN($tester_infoAr['puntatore']); if ($tester_dsn != NULL) { $tester_dh = AMA_DataHandler::instance($tester_dsn); $result[$tester_infoAr['puntatore']] = array_merge($result[$tester_infoAr['puntatore']], $tester_dh->get_new_nodes($userId)); } } return $result; }
$errObj = new ADA_Error($testersAr, translateFN("Errore nell'ottenimento delle informazioni sui tester")); } else { $testersAr = array(); foreach ($testers_dataAr as $tester_dataAr) { $testersAr[$tester_dataAr['puntatore']] = $tester_dataAr['nome']; } $form = AdminModuleHtmlLib::getAddUserForm($testersAr, $user_dataAr, $errorsAr); } } } } else { /* * Display the add user form */ $testers_dataAr = $common_dh->get_all_testers(array('id_tester', 'nome')); if (AMA_Common_DataHandler::isError($testers_dataAr)) { $errObj = new ADA_Error($testersAr, translateFN("Errore nell'ottenimento delle informazioni sui tester")); } else { $testersAr = array(); foreach ($testers_dataAr as $tester_dataAr) { $testersAr[$tester_dataAr['puntatore']] = $tester_dataAr['nome']; } $form = AdminModuleHtmlLib::getAddUserForm($testersAr); } } $label = translateFN("Aggiunta utente"); $help = translateFN("Da qui l'amministratore puo' creare un nuovo utente"); $home_link = CDOMElement::create('a', 'href:admin.php'); $home_link->addChild(new CText(translateFN("Home dell'Amministratore"))); $module = $home_link->getHtml() . ' > ' . $label; $menu_dataAr = array();
/** * Wrapper function for read_user_from_DB. * @see read_user_from_DB */ function read_user($id_user = NULL) { /* * Return the user object in sess_userObj */ if (is_null($id_user)) { $sess_userObj = $_SESSION['sess_userObj']; if ($sess_userObj instanceof ADAGenericUser) { return $sess_userObj; } return new ADA_Error(NULL, translateFN('Errore in lettura oggetto utente in sessione'), 'read_user', NULL, NULL, NULL, TRUE); } // FIXME: qui $id_user diventa ZERO. VEDIAMO DI CAPIRE PERCHE'. //$id_user = is_int($id_user) ? $id_user : 0; if (isset($_SESSION['sess_id_user']) && $id_user === $_SESSION['sess_id_user']) { $sess_userObj = $_SESSION['sess_userObj']; if ($sess_userObj instanceof ADAGenericUser && $sess_userObj->getId() == $id_user) { // QUI DEVO VEDERE QUALI SONO I TESTER ASSOCIATI A QUESTO UTENTE. $user_testersAr = $GLOBALS['common_dh']->get_testers_for_user($id_user); if (!AMA_Common_DataHandler::isError($user_testersAr)) { $sess_userObj->setTesters($user_testersAr); $_SESSION['sess_userObj'] = $sess_userObj; } return $_SESSION['sess_userObj']; } } return read_user_from_DB($id_user); }
$self = whoami(); // to select the right template /* * 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) {
$availableLanguages = Translator::getSupportedLanguages(); $languages = array(); foreach ($availableLanguages as $language) { $languages[$language['id_lingua']] = $language['nome_lingua']; } $form = new CourseModelForm($authors, $languages); $form->fillWithPostData(); if ($form->isValid()) { $course = array('nome' => isset($_POST['nome']) ? $_POST['nome'] : null, 'titolo' => isset($_POST['titolo']) ? $_POST['titolo'] : null, 'descr' => isset($_POST['descrizione']) ? $_POST['descrizione'] : null, 'd_create' => isset($_POST['data_creazione']) ? $_POST['data_creazione'] : null, 'd_publish' => isset($_POST['data_pubblicazione']) ? $_POST['data_pubblicazione'] : null, 'id_autore' => isset($_POST['id_utente_autore']) ? $_POST['id_utente_autore'] : null, 'id_nodo_toc' => isset($_POST['id_nodo_toc']) ? $_POST['id_nodo_toc'] : null, 'id_nodo_iniziale' => isset($_POST['id_nodo_iniziale']) ? $_POST['id_nodo_iniziale'] : null, 'media_path' => isset($_POST['media_path']) ? $_POST['media_path'] : null, 'id_lingua' => isset($_POST['id_lingua']) ? $_POST['id_lingua'] : null, 'static_mode' => isset($_POST['static_mode']) ? $_POST['static_mode'] : null, 'crediti' => isset($_POST['crediti']) ? $_POST['crediti'] : null, 'duration_hours' => isset($_POST['duration_hours']) ? $_POST['duration_hours'] : null, 'service_level' => isset($_POST['service_level']) ? $_POST['service_level'] : null); $result = $dh->set_course($_POST['id_corso'], $course); if (!AMA_DataHandler::isError($result)) { $service_dataAr = $common_dh->get_service_info_from_course($_POST['id_corso']); if (!AMA_Common_DataHandler::isError($service_dataAr)) { $update_serviceDataAr = array('service_name' => $_POST['titolo'], 'service_description' => $_POST['descrizione'], 'service_level' => $_POST['service_level'], 'service_duration' => $service_dataAr[4], 'service_min_meetings' => $service_dataAr[5], 'service_max_meetings' => $service_dataAr[6], 'service_meeting_duration' => $service_dataAr[7]); $result = $common_dh->set_service($service_dataAr[0], $update_serviceDataAr); if (AMA_Common_DataHandler::isError($result)) { $form = new CText("Si è verificato un errore durante l'aggiornamento dei dati del corso"); } else { // AGGIORNARE l'oggetto corso in sessione e poi fare il redirect a view_course.php //header('Location: view_course.php?id_course=' . $_POST['id_corso']); header('Location: list_courses.php'); exit; } } } else { $form = new CText("Si è verificato un errore durante l'aggiornamento dei dati del corso"); } } else { $form = new CText('Form non valido'); } } else {
if ($event_token === FALSE) { $errObj = new ADA_Error(NULL, translateFN("Dati in input per il modulo eguidance_tutor_form non corretti"), NULL, NULL, NULL, $userObj->getHomePage()); } } else { $errObj = new ADA_Error(NULL, translateFN("Dati in input per il modulo eguidance_tutor_form non corretti"), NULL, NULL, NULL, $userObj->getHomePage()); } $id_course_instance = ADAEventProposal::extractCourseInstanceIdFromThisToken($event_token); /* * Get service info */ $id_course = $dh->get_course_id_for_course_instance($id_course_instance); if (AMA_DataHandler::isError($id_course)) { $errObj = new ADA_Error(NULL, translateFN("Errore nell'ottenimento dell'id del servzio"), NULL, NULL, NULL, $userObj->getHomePage()); } $service_infoAr = $common_dh->get_service_info_from_course($id_course); if (AMA_Common_DataHandler::isError($service_infoAr)) { $errObj = new ADA_Error(NULL, translateFN("Errore nell'ottenimento delle informazioni sul servizio"), NULL, NULL, NULL, $userObj->getHomePage()); } $users_infoAr = $dh->course_instance_students_presubscribe_get_list($id_course_instance); if (AMA_DataHandler::isError($users_infoAr)) { $errObj = new ADA_Error($users_infoAr, translateFN("Errore nell'ottenimento dei dati dello studente"), NULL, NULL, NULL, $userObj->getHomePage()); } /* * Get tutored user info */ /* * In ADA only a student can be subscribed to a specific course instance * if the service has level < 4. * TODO: handle form generation for service with level = 4 and multiple users * subscribed. */
include_once ROOT_DIR . '/include/HtmlLibrary/BaseHtmlLib.inc.php'; $tutor_id = DataValidator::is_uinteger($_GET['id']); if ($tutor_id == false) { header('Location: ' . $userObj->getHomePage()); exit; } $tutor_ha = $dh->get_tutor($tutor_id); if (AMA_DataHandler::isError($tutor_ha)) { $errObj = new ADA_Error($tutor_ha, translateFN('An error occurred while reading tutor data.')); } //$tutored_users_number = $dh->get_number_of_tutored_users($id); $tutored_user_ids = $dh->get_tutored_user_ids($id); if (AMA_DataHandler::isError($tutored_user_ids)) { $errObj = new ADA_Error($tutored_user_ids, translateFN('An error occurred while reading tutored user ids')); } $number_of_active_tutored_users = $common_dh->get_number_of_users_with_status($tutored_user_ids, ADA_STATUS_REGISTERED); if (AMA_Common_DataHandler::isError($number_of_active_tutored_users)) { $errObj = new ADA_Error($number_of_active_tutored_users, translateFN('An error occurred while retrieving the number of active tutored users.')); } $tutor_ha['utenti seguiti'] = $number_of_active_tutored_users; unset($tutor_ha['tipo']); unset($tutor_ha['layout']); unset($tutor_ha['tariffa']); unset($tutor_ha['codice_fiscale']); $data = BaseHtmlLib::plainListElement('', $tutor_ha); $banner = (include ROOT_DIR . '/include/banner.inc.php'); $status = translateFN('Caratteristiche del practitioner'); // preparazione output HTML e print dell' output $title = translateFN('ADA - dati epractitioner'); $content_dataAr = array('menu' => $menu, 'banner' => $banner, 'dati' => $data->getHtml(), 'help' => $help, 'status' => $status, 'user_name' => $user_name, 'edit_profile' => $userObj->getEditProfilePage(), 'user_type' => $user_type, 'messages' => $user_messages->getHtml(), 'agenda' => $user_agenda->getHtml()); ARE::render($layout_dataAr, $content_dataAr);