Beispiel #1
0
 function get_linksFN($user_level, $id_profile)
 {
     //global $dh,$error,$debug;
     //global $sess_id_course,$sess_id_course_instance,$sess_id_user;
     $dh = isset($GLOBALS['dh']) ? $GLOBALS['dh'] : null;
     $error = isset($GLOBALS['error']) ? $GLOBALS['error'] : null;
     $debug = isset($GLOBALS['debug']) ? $GLOBALS['debug'] : null;
     $sess_id_course = isset($_SESSION['sess_id_course']) ? $_SESSION['sess_id_course'] : null;
     $sess_id_course_instance = isset($_SESSION['sess_id_course_instance']) ? $_SESSION['sess_id_course_instance'] : null;
     $sess_id_user = isset($_SESSION['sess_id_user']) ? $_SESSION['sess_id_user'] : null;
     // filtro sui link:
     // verifica se i nodi linkati hanno livello<= a quello dell'utente
     if (!empty($this->links)) {
         $linkAr = $this->links;
         // mydebug(__LINE__,__FILE__,$linkAr);
         $dataAr = array();
         foreach ($linkAr as $id_link) {
             $linkObj = new Link($id_link);
             $id_linked_node = $linkObj->to_node_id;
             $link_meaning = translatefN("Tipo:") . $linkObj->meaning;
             $node = $id_linked_node;
             $tempNodeObj = new Node($node, 0);
             if ($tempNodeObj->full == 1) {
                 $linked_node_name = $tempNodeObj->name;
                 $linked_node_level = $tempNodeObj->level;
                 if ($linked_node_level <= $user_level) {
                     switch ($id_profile) {
                         case AMA_TYPE_STUDENT:
                         default:
                             $visit_count = ADALoggableUser::is_visited_by_userFN($node, $sess_id_course_instance, $sess_id_user);
                             break;
                         case AMA_TYPE_TUTOR:
                             $visit_count = ADALoggableUser::is_visited_by_classFN($node, $sess_id_course_instance, $sess_id_user);
                             break;
                         case AMA_TYPE_AUTHOR:
                             $visit_count = ADALoggableUser::is_visitedFN($node);
                     }
                     if ($visit_count <= 0) {
                         $ok_link = array("<img src=\"img/_linka.png\">", "&nbsp;<a class='node_not_visited' href=view.php?id_node={$node} alt=\"{$link_meaning}\">{$linked_node_name}</a>");
                     } else {
                         $ok_link = array("<img src=\"img/_linka.png\">", "&nbsp;<a href=view.php?id_node={$node} alt=\"{$link_meaning}\">{$linked_node_name}</a> ({$visit_count})");
                     }
                 } else {
                     $ok_link = array("<img src=\"img/_linkdis.png\">", "&nbsp; " . $linked_node_name);
                     // $ok_link = array("<img src=\"templates/default/img/_linkdis.png\">",$linked_node_name);
                 }
             } else {
                 //$ok_link =array("&nbsp;","&nbsp;");
                 $ok_link = array("<img src=\"img/_linkdis.png\" alt=\"{$node}\">", translateFN("nodo non trovato"));
             }
             array_push($dataAr, $ok_link);
         }
         $dataAr = $this->_removeEmptyElements($dataAr);
         $t = new Table();
         $rules = '';
         $style = 'table_link';
         $t->initTable('0', 'center', '0', '0', '100%', '', '', '', '', '0', '0', $rules, $style);
         $t->setTable($dataAr, $caption = "", $summary = translateFN("Indice dei nodi collegati"));
         return $t->getTable();
     } else {
         return $this->_wrapTextInSpan(translateFN('Nessuno'), 'noitem')->getHtml();
     }
 }