Exemplo n.º 1
0
function add_request($user_id, $type = 0)
{
    // insert user_id, date, type  into table "requests"
    $date = AMA_DataHandler::date_to_ts("now");
    $token = sha1($date);
    // o altro algoritmo
    $status = ADA_REQUEST_STATUS_SET;
    // insert  $date, $userid, $token, $type, $status
    // if ok:
    return $token;
}
Exemplo n.º 2
0
 public function course_instance_subscribeable_get_list($field_list_ar, $courseId)
 {
     $today_date = today_dateFN();
     $timestamp = AMA_DataHandler::date_to_ts($today_date);
     //        $timestamp = time();
     //        return $this->course_instance_find_list($field_list_ar, "id_corso=$courseId AND self_registration=1 AND data_inizio=0 AND data_inizio_previsto >= $timestamp and durata > 0  ORDER BY data_inizio_previsto ASC");
     return $this->course_instance_find_list($field_list_ar, "id_corso={$courseId} AND self_registration=1 AND open_subscription=1 ORDER BY data_inizio_previsto ASC");
 }
Exemplo n.º 3
0
 $testerId = $tester_infoHa['id_tester'];
 // it is an integer
 // find tester DH from tester pointer
 $tester_dh = AMA_DataHandler::instance(MultiPort::getDSN($tester));
 $serviceObj = Service::findServiceFromImplementor($id_course);
 $serviceAr = $serviceObj->get_service_info();
 $service_name = $serviceAr[0];
 //  get service from course
 $serviceinfoAr = $common_dh->get_service_info_from_course($id_course);
 if (AMA_DataHandler::isError($serviceinfoAr)) {
     $message = urlencode(translateFN('Impossibile richiedere il servizio'));
     $errObj = new ADA_Error($serviceinfoAr, $message, NULL, NULL, NULL, $error_page . '?message=' . $message);
     exit;
 }
 $start_date1 = 0;
 $start_date2 = AMA_DataHandler::date_to_ts("now");
 $days = $serviceinfoAr[4];
 $istanza_ha = array('data_inizio' => $start_date1, 'durata' => $days, 'data_inizio_previsto' => $start_date2, 'id_layout' => NULL);
 // add user to tester DB
 $id_tester_user = Multiport::setUser($userObj, $testersAr, $update_user_data = FALSE);
 if ($id_tester_user === FALSE) {
     $message = urlencode(translateFN("Error while assigning user to provider."));
     //  header('Location:'.$userObj->getHomepage($message));
     // exit();
 }
 // add an instance to tester db
 $res_inst_add = $tester_dh->course_instance_add($id_course, $istanza_ha);
 if (!AMA_DataHandler::isError($res_inst_add) or $res_inst_add->code == AMA_ERR_UNIQUE_KEY) {
     // we add an instance OR there already was one with same data
     // get an instance
     $clause = "id_corso = {$id_course} AND data_inizio_previsto = {$start_date2} AND durata  = {$days}";
Exemplo n.º 4
0
 /**
  * get all services to which a given user has subscribed
  * @param  $ADAUser $userObj
  * @param  $field_list_ar array
  * @param  $clause string
  * @return $sub_course_dataHa array
  */
 public static function find_sub_services_data(ADAGenericUser $userObj, $field_ar, $clause, $orderBy = 'service')
 {
     $common_dh = $GLOBALS['common_dh'];
     $sub_course_dataHa = array();
     $user_id = $userObj->getId();
     /*
      * Obtain tester names
      */
     $tester_names = array();
     /*    foreach ($userObj->getTesters() as $tester) {
           $tester_dataHa = $common_dh->get_tester_info_from_pointer($tester);
           $tester_names[$tester] = $tester_dataHa[1];
         }
     */
     // foreach($userObj->getTesters() as $tester) { // only providers in which user is subscribed
     /*  $testers = $common_dh->get_all_testers(); // all providers
         foreach($testers as $testerItem){
       	  $tester = $testerItem['puntatore'];
     */
     $testerPointersAr = $common_dh->get_testers_for_user($user_id);
     // providers assigned to the user
     foreach ($testerPointersAr as $tester) {
         // ADALogger::log("MultiPort::find_sub_services_data for tester: $tester");
         $tester_dataHa = $common_dh->get_tester_info_from_pointer($tester);
         $tester_city = $tester_dataHa[5];
         $tester_country = $tester_dataHa[6];
         $tester_names[$tester] = $tester_dataHa[1];
         $tester_dsn = self::getDSN($tester);
         if ($tester_dsn != null) {
             //$tester_dataHa = $common_dh->get_tester_info_from_pointer($tester);
             //$tester_name = 'NOME TESTER';//$tester_dataHa[1];
             $tester_dh = AMA_DataHandler::instance($tester_dsn);
             if (!AMA_DataHandler::isError($tester_dh)) {
                 // versioneche cicla solo sulle istanze cui è pre/iscritto
                 $all_instance = $tester_dh->course_instance_student_presubscribe_get_status($user_id);
                 //  versioneche cicla su tutte le istanze
                 /* FIXME: bisogna fare una JOIN su iscrizione e istanze_corso !
                     	    $all_instance = $tester_dh->course_instance_find_list($field_ar,$clause);
                 			var_dump($all_instance);
                 			*/
             } else {
                 //var_dump($tester_dh);
                 $all_instance = "";
             }
             if (is_array($all_instance)) {
                 foreach ($all_instance as $one_instance) {
                     //	  var_dump($one_instance);
                     $history_link = " - ";
                     $toc = " - ";
                     $info = "- ";
                     $tutor = translateFN("Not assigned");
                     $tutor_link = $tutor;
                     $now = AMA_DataHandler::date_to_ts("now");
                     $id_course_instance = $one_instance['istanza_corso'];
                     $status = $one_instance['status'];
                     $one_course_instance = $tester_dh->course_instance_get($id_course_instance, true);
                     // GESTIRE ERRORE
                     $id_course = $one_course_instance['id_corso'];
                     $data_inizio = $one_course_instance['data_inizio'];
                     $durata = $one_course_instance['durata'];
                     // NOTE: qui sarebbe utile invece il conto dei giorni restanti...
                     $data_inizio_previsto = $one_course_instance['data_inizio_previsto'];
                     $data_fine = $one_course_instance['data_fine'];
                     $service_completed = $data_fine < $now;
                     $sub_courses = $tester_dh->get_subscription($user_id, $id_course_instance);
                     //      if ($sub_courses['tipo'] == 2) { introducing status 3 (removed) and 4 (visitors)
                     if (!AMA_dataHandler::isError($sub_courses)) {
                         //    if (($sub_courses['tipo'] == ADA_STATUS_SUBSCRIBED) OR ($sub_courses['tipo'] == 4)) {
                         /* hack: subscription state is not updated, so we use time from course instance data to show users' status*/
                         if ($service_completed && $sub_courses['tipo'] == ADA_SERVICE_SUBSCRIPTION_STATUS_ACCEPTED) {
                             $tipo = ADA_SERVICE_SUBSCRIPTION_STATUS_COMPLETED;
                         } else {
                             $tipo = $sub_courses['tipo'];
                         }
                         // filtering on completed services if $clause paratemer is passed
                         if (!$clause or $tipo != ADA_SERVICE_SUBSCRIPTION_STATUS_COMPLETED) {
                             //FIXME: we have to parse the clause !!!
                             $tutor_Id = $tester_dh->course_instance_tutor_get($id_course_instance);
                             if ($tutor_Id) {
                                 $tutorInfoHa = $tester_dh->get_tutor($tutor_Id);
                                 $tutor_link = '<a href="' . HTTP_ROOT_DIR . '/browsing/practitionerProfile.php?id=' . $tutor_Id . '">' . $tutorInfoHa['nome'] . ' ' . $tutorInfoHa['cognome'] . '</a>';
                             }
                             $course = $tester_dh->get_course($id_course);
                             if (is_array($course)) {
                                 $id_start = $id_course . "_" . $course['id_nodo_iniziale'];
                                 $home_label = translateFN("home");
                                 $titolo = translateFN($course['titolo']);
                                 $info = "<a href=" . $http_root_dir . "../info.php?id_course={$id_course}&norequest=1>{$titolo}</a>";
                                 $start_date = ts2dFN($data_inizio_previsto);
                             }
                             // mod steve 17/12/09 suspended while wating for  history module
                             // $history_link = "<a href='".HTTP_ROOT_DIR."/browsing/service_info.php?norequest=1&id_course=$id_course&id_course_instance=$id_course_instance'>$start_date</a>";
                             $nome = $course['nome'];
                             switch ($tipo) {
                                 case ADA_SERVICE_SUBSCRIPTION_STATUS_ACCEPTED:
                                     //ADA_STATUS_SUBSCRIBED:
                                     // mod steve 17/12/09 suspended while wating for  history module
                                     $history_link = "<a href='" . HTTP_ROOT_DIR . "/browsing/service_info.php?norequest=1&id_course={$id_course}&id_course_instance={$id_course_instance}'>{$start_date}</a> - " . ts2dFN($data_fine);
                                     // $history_link =  $start_date;
                                     $toc = "<a href='view.php?{$session_id_par}" . "id_course={$id_course}&id_node={$id_start}&id_course_instance={$id_course_instance}'>" . translateFN('Entra') . "</a>";
                                     break;
                                 case ADA_SERVICE_SUBSCRIPTION_STATUS_REQUESTED:
                                     //ADA_STATUS_PRESUBSCRIBED:
                                     // $toc = "<a href='view.php?$session_id_par"."id_course=$id_course&id_node=$id_start&id_course_instance=$id_course_instance'>".translateFN('Entra'). "</a>";
                                     $history_link = $start_date . " - " . ts2dFN($data_fine);
                                     break;
                                 case ADA_SERVICE_SUBSCRIPTION_STATUS_COMPLETED:
                                     $history_link = $start_date . " - " . ts2dFN($data_fine);
                                     break;
                                 case ADA_SERVICE_SUBSCRIPTION_STATUS_SUSPENDED:
                                     $history_link = $start_date . " - ";
                                     break;
                                 case ADA_SERVICE_SUBSCRIPTION_STATUS_UNDEFINED:
                                 default:
                                     // es ADA_STATUS_VISITOR = 4
                             }
                             //case
                             // subscription state
                             $subscription_state = subscriptionType2stringFN($tipo);
                             if ($orderBy == "country") {
                                 $row = array(translateFN('Country') => $tester_country . "/" . $tester_city, translateFN('Provider') => $tester_names[$tester], translateFN('Servizio') => $info, translateFN('Dettagli') => $toc, translateFN('Period') => $history_link, translateFN('Durata') => $durata, translateFN('E-practitioner') => $tutor_link, translateFN('Stato') => $subscription_state);
                             } else {
                                 // default
                                 $row = array(translateFN('Servizio') => $info, translateFN('Country') => $tester_country . "/" . $tester_city, translateFN('Provider') => $tester_names[$tester], translateFN('Dettagli') => $toc, translateFN('Period') => $history_link, translateFN('Durata') => $durata, translateFN('E-practitioner') => $tutor_link, translateFN('Stato') => $subscription_state);
                             }
                             // mydebug(__LINE__,__FILE__,$row);
                             array_push($sub_course_dataHa, $row);
                         } else {
                             //$sub_course_dataHa = ""; // translateFN("Nessuna iscrizione");
                         }
                     }
                     // if not completed
                 }
                 // foreach instance
             }
         }
     }
     // foreach er
     return $sub_course_dataHa;
 }