function get_user_mediaFN($user_level) { // indexing files $root_dir = isset($GLOBALS['root_dir']) ? $GLOBALS['root_dir'] : null; $http_root_dir = isset($GLOBALS['http_root_dir']) ? $GLOBALS['http_root_dir'] : null; $sess_id_course_instance = isset($_SESSION['sess_id_course_instance']) ? $_SESSION['sess_id_course_instance'] : null; $sess_id_course = isset($_SESSION['sess_id_course']) ? $_SESSION['sess_id_course'] : null; $sess_id_node = isset($_SESSION['sess_id_node']) ? $_SESSION['sess_id_node'] : null; //$sess_id_node = $GLOBALS['sess_id_node']; $dh = $GLOBALS['dh']; $course_ha = $dh->get_course($sess_id_course); if (AMA_DataHandler::isError($course_ha)) { // not enrolled yet? return $this->_wrapTextInSpan(translateFN('Nessuno'), 'noitem')->getHtml(); } $author_id = $course_ha['id_autore']; $elencofile = $this->read_user_dirFN("{$root_dir}/services/media/{$author_id}"); if ($elencofile == NULL) { //($stop<1) return $this->_wrapTextInSpan(translateFN('Nessuno'), 'noitem')->getHtml(); } $fcount = count($elencofile); $media = ""; $dataAr = array(); $lObj = new IList(); $lObj->initList('0', 'disc', 1); /* for ($i=0; $i<$fcount; $i++){ $data = $elencofile[$i]['data']; $complete_file_name = $elencofile[$i]['file']; // rebuilding true file name // rootdir + media path + author_id + id_course_instance + user_id + course_id + node_id + filename // ex. 111_27_113_0_example.txt' $filenameAr = explode('_',$complete_file_name); $stop = count($filenameAr)-1; $course_instance = $filenameAr[0]; $id_sender = $filenameAr[1]; if (is_numeric($id_sender)) { $id_node = $filenameAr[2]."_".$filenameAr[3]; $filename = ""; for ($k = 4; $k<=$stop;$k++){ $filename .= $filenameAr[$k]; if ($k<$stop) $filename .= "_"; } $senderObj = read_user_from_DB($id_sender); if ((is_object($senderObj)) || (!empty($senderObj->error_msg))) { $id_profile = $senderObj->tipo; switch ($id_profile){ case AMA_TYPE_STUDENT: case AMA_TYPE_AUTHOR: case AMA_TYPE_TUTOR: $user_name = $senderObj->username; break; default: // errore $sender_error = 1; } } if ((!$sender_error) && ($course_instance == $sess_id_course_instance)){ if (($id_node == $sess_id_node)) array_push($dataAr,"<a href=\"$http_root_dir/user/index.php?module=download.php&file=$complete_file_name\" target=_blank>$filename</a> <br> $user_name : $data"); } } } */ // vito, 30 mar 2009 /* * Create a mediaviewer */ $media_path = $GLOBALS['media_path']; if (MEDIA_LOCAL_PATH) { $http_file_path = MEDIA_LOCAL_PATH . $media_path; } else { $http_file_path = $http_root_dir . $media_path; } $VIEWINGPREFERENCES = array(_IMAGE => IMG_VIEWING_MODE, _SOUND => AUDIO_PLAYING_MODE, _VIDEO => VIDEO_PLAYING_MODE, INTERNAL_LINK => 0, _DOC => DOC_VIEWING_MODE, _LINK => 0); $user_data = array('level' => $user_level, 'id_course' => $sess_id_course); $mediaviewer = new MediaViewer($http_file_path, $user_data, $VIEWINGPREFERENCES); // end of vito, 30 mar 2009 $dataAr = array(); for ($i = 0; $i < $fcount; $i++) { $data = $elencofile[$i]['data']; $complete_file_name = $elencofile[$i]['file']; // rebuilding true file name // rootdir + media path + author_id + filename + id_course_instance + user_id + node_id // ex. 111_27_113_0_example.txt' $filenameAr = explode('_', $complete_file_name); $stop = count($filenameAr) - 1; $course_instance = $filenameAr[0]; $id_sender = isset($filenameAr[1]) ? $filenameAr[1] : null; if (is_numeric($id_sender)) { $fid_node = $filenameAr[2] . "_" . (isset($filenameAr[3]) ? $filenameAr[3] : ''); $filename = ""; // vito, 30 mar 2009 $this_file_type = isset($filenameAr[4]) ? $filenameAr[4] : null; //for ($k = 4; $k<=$stop;$k++){ for ($k = 5; $k <= $stop; $k++) { $filename .= $filenameAr[$k]; if ($k < $stop) { $filename .= "_"; } } $sender_error = 0; $user_name = ""; // too slow ! /* $senderObj = read_user_from_DB($id_sender); if ((is_object($senderObj))) { $id_profile = $senderObj->tipo; switch ($id_profile){ case AMA_TYPE_STUDENT: case AMA_TYPE_AUTHOR: case AMA_TYPE_TUTOR: $user_name = $senderObj->username; break; default: // errore $sender_error = 1; } } */ if (!$sender_error && $course_instance == $sess_id_course_instance) { // if (!isset($fid_node) || ($fid_node == $sess_id_node)) ?? if ($fid_node == $sess_id_node) { //array_push($dataAr,"<a href=\"$http_root_dir/user/index.php?module=download.php&file=$complete_file_name\" target=_blank>".substr($filename,0,8)."...</a> <br> $user_name : $data"); // vito, 30 mar 2009 //array_push($dataAr,"<a href=\"$http_root_dir/browsing/download.php?file=$complete_file_name\" target=_blank>".substr($filename,0,8)."...</a> <br> $user_name : $data"); if (is_numeric($this_file_type)) { $dataAr[] = $mediaviewer->getMediaLink(array(null, $this_file_type, $filename, $elencofile[$i]['file'], $elencofile[$i]['path_to_file'])); } } } } } if (count($dataAr)) { $lObj->setList($dataAr); $var = $lObj->getList(); $media .= "{$var}</p>\n"; return $media; } else { return $this->_wrapTextInSpan(translateFN('Nessuno'), 'noitem')->getHtml(); } }
function export_bookmarks($dataAr, $mode = 'ada') { $dh = $GLOBALS['dh']; $error = $GLOBALS['error']; $http_root_dir = $GLOBALS['http_root_dir']; $debug = $GLOBALS['debug']; if (!is_array($dataAr) || !count($dataAr)) { $res = translateFN("Nessun segnalibro"); // header("Location: $error?err_msg=$msg"); } else { if ($mode == 'standard') { $formatted_data = "<a href=\"bookmarks.php?op=export&mode=ada\" >" . translateFN("Formato ADA") . "</a> | "; $formatted_data .= translateFN("Formato Standard") . "<p>"; } else { $formatted_data = translateFN("Formato ADA") . " | "; $formatted_data .= "<a href=\"bookmarks.php?op=export&mode=standard\" >" . translateFN("Formato Standard") . "</a><p>"; } $formatted_data .= "<form><textarea rows=10 cols=80 wrap=virtual>\n"; $ilist_data = array(); foreach ($dataAr as $bookmark) { $id_bk = $bookmark[0]; $id_node = $bookmark[1]; $date = $bookmark[2]; $node = $dh->get_node_info($id_node); $title = $node['name']; $description = $bookmark[3]; if ($mode == 'standard') { //formato standard //$formatted_data.="<li><a href=\"$http_root_dir/browsing/view.php?id_node=$id_node\" alt=\"$title\"> $title </a></li>\n"; $list_item = "<a href=\"{$http_root_dir}/browsing/view.php?id_node={$id_node}\" alt=\"{$title}\"> {$title} </a>"; $ilist_data[] = $list_item; } else { $c_n = explode('_', $id_node); $num_node = $c_n[1]; // formato ADA // $formatted_data.="<li>$title <LINK TYPE=internal VALUE=\"$num_node\"></li>\n"; $list_item = "{$title} <LINK TYPE=internal VALUE=\"{$num_node}\">"; $ilist_data[] = $list_item; } } $lObj = new IList(); $lObj->initList('1', 'a', 3); $lObj->setList($ilist_data); $formatted_data .= $lObj->getList(); $formatted_data .= "</textarea></form>\n</p>\n"; } return $formatted_data; }