$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 IPN\n");
    fwrite($fpx, "Prima di init \n");
}
$today_date = today_dateFN();
$providerId = DataValidator::is_uinteger($_REQUEST['provider']);
$courseId = DataValidator::is_uinteger($_REQUEST['course']);
$instanceId = DataValidator::is_uinteger($_REQUEST['instance']);
$studentId = DataValidator::is_uinteger($_REQUEST['student']);
$testerInfoAr = $common_dh->get_tester_info_from_id($providerId, 'AMA_FETCH_ASSOC');
$buyerObj = read_user($studentId);
if (is_object($buyerObj) && !AMA_dataHandler::isError($buyerObj)) {
    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;
        // id dello studente
        if (!isset($instanceId)) {
            $instanceId = $sess_id_user;
            // ??????
        }
        /*
         * Instance Object
         */
Exemplo n.º 2
0
$start_date = AMA_DataHandler::ts_to_date($courseInstanceObj->data_inizio, "%d/%m/%Y");
$history = '';
if ($id_course) {
    // get object course
    $courseObj = read_course_from_DB($id_course);
    if (is_object($courseObj) && !AMA_dataHandler::isError($courseObj)) {
        $course_title = $courseObj->titolo;
        //title
        $id_toc = $courseObj->id_nodo_toc;
        //id_toc_node
    } else {
        $errObj = new ADA_error(translateFN("Corso non trovato"), translateFN("Impossibile proseguire."));
    }
}
$studentObj = read_user_from_DB($id_student);
if (is_object($studentObj) && !AMA_dataHandler::isError($studentObj)) {
    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();
    }
    $studentObj->set_course_instance_for_history($id_course_instance);
    $id_profile_student = $studentObj->tipo;
    $user_name_student = $studentObj->username;
    $student_name = $studentObj->nome . " " . $studentObj->cognome;
    $user_historyObj = $studentObj->history;
    $user_level = $studentObj->livello;
Exemplo n.º 3
0
 /**
  * get the tutor(s) of the course_instance
  *
  * @access public
  *
  * @param $id_tutor    - tutor id
  * @param $id_instance    - course instance id
  * @param $number    - mode: a single tutor  or array
  *
  * @return an error if something goes wrong, an array if $number >=1, an integer else
  */
 public function course_instance_tutor_get($id_instance, $number = 1)
 {
     $db =& $this->getConnection();
     if (AMA_DB::isError($db)) {
         return $db;
     }
     // select row(s) into table tutor_studenti
     $sql = "select id_utente_tutor from tutor_studenti where id_istanza_corso={$id_instance}";
     if ($number == 1) {
         $res = $db->getRow($sql);
     } else {
         $res = $db->getAll($sql);
     }
     if (AMA_DB::isError($res)) {
         return new AMA_Error(AMA_ERR_GET);
     }
     if (!empty($res) && !AMA_dataHandler::isError($res)) {
         if ($number == 1) {
             $id_utente_tutor = $res[0];
             return $id_utente_tutor;
         } else {
             $tutorAr = array();
             foreach ($res as $tutor) {
                 $id_utente_tutor = $tutor[0];
                 $tutorAr[] = $id_utente_tutor;
             }
             return $tutorAr;
         }
     }
     // no tutor found
     return false;
 }
Exemplo n.º 4
0
        }
    }
}
if (in_array('tutor', $thisUserNeededObjAr)) {
    /**
     *  get Tutor Object
     */
    if (isset($sess_id_course_instance)) {
        if ($user_status != ADA_STATUS_VISITOR) {
            $tutor_id = $dh->course_instance_tutor_get($sess_id_course_instance);
            if (!empty($tutor_id) && !AMA_dataHandler::isError($tutor_id)) {
                /**
                 * @var Object
                 */
                $tutorObj = $dh->get_tutor($tutor_id);
                if (!AMA_dataHandler::isError($tutorObj)) {
                    if (isset($tutor['username'])) {
                        $tutor_uname = $tutor['username'];
                    }
                }
            }
        }
    }
}
if (in_array('node', $thisUserNeededObjAr)) {
    /**
     *  get Node Object
     */
    /**
     * @var Object
     */
Exemplo n.º 5
0
 function findLogicalPathFN()
 {
     // NON ricorsivamente tenta di risalire al nodo id X_0
     // ritorna un array bidimensionale di coppie id_node/name
     $dh = $GLOBALS['dh'];
     $error = $GLOBALS['error'];
     $self = $GLOBALS['self'];
     $sess_id_course = $_SESSION['sess_id_course'];
     /*
     $courseObj = new Course($sess_id_course);
     $id_toc =  $sess_id_course."_".$courseObj->id_nodo_toc;
     */
     $pathAr = array();
     $course_Ha = $dh->get_course($sess_id_course);
     if (is_array($course_Ha)) {
         $id_toc = $sess_id_course . "_" . $course_Ha['id_nodo_toc'];
         // $id_toc = $sess_id_course."_0";
         $id_node = $this->id;
         $name = $this->name;
         $pathAr[] = array($id_node, $name);
         //""
         // vito, 12 giugno 2009
         //         if ($id_node==$id_toc){   // are we at main group level?
         //           // vito, 12 giugno 2009
         //           //  $pathAr[] = "";
         //         }
         //         else {
         if ($id_node != $id_toc) {
             //$name = $this->name;
             $id_parent = $this->parent_id;
             while ($id_node != $id_toc && !empty($id_node) && $id_node != "NULL") {
                 // $debug=1;
                 //mydebug(__LINE__,__FILE__,array('node'=>$id_node,'parent'=>$id_parent));
                 //$debug=0;
                 $dataHa = $dh->get_node_info($id_parent);
                 if (!AMA_dataHandler::isError($dataHa) && is_array($dataHa)) {
                     $name = $dataHa['name'];
                     $id_node = $dataHa['parent_id'];
                     if ($id_parent != $id_toc) {
                         //$node_parentObj = new Node($id_node);
                         //$parent_type = $node_parentObj->type;
                         $node_parent_dataHa = $dh->get_node_info($id_node);
                         if (!is_object($node_parent_dataHa)) {
                             $parent_type = $node_parent_dataHa['type'];
                             //if ($parent_type ==ADA_GROUP_TYPE) {
                             $pathAr[] = array($id_parent, $name);
                             //mydebug(__LINE__,__FILE__,array('name'=>$name,'parent'=>$id_node));
                         } else {
                         }
                         $id_parent = $id_node;
                     }
                 } else {
                     $id_node = "";
                 }
             }
             // we are at the first level
             $dataHa = $dh->get_node_info($id_toc);
             if (is_array($dataHa)) {
                 $tocname = $dataHa['name'];
                 $pathAr[] = array($id_toc, $tocname);
             }
         }
     }
     return $pathAr;
 }
Exemplo n.º 6
0
 // 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'];
         switch ($c_type) {
             case PUBLIC_CHAT:
                 $chat_type = translateFN("pubblica");
                 break;
             case CLASS_CHAT:
                 $chat_type = translateFN("classe");
Exemplo n.º 7
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;
 }