function get_mediaFN_OLD($user_level) { $HTTP_USER_AGENT = $GLOBALS['HTTP_USER_AGENT']; $dh = $GLOBALS['dh']; $error = $GLOBALS['error']; $media_path = $GLOBALS['media_path']; $root_dir = $GLOBALS['root_dir']; $http_root_dir = $GLOBALS['http_root_dir']; $sess_id_course = $_SESSION['sess_id_course']; $debug = $GLOBALS['debug']; $node_level = $this->level; if ($node_level <= $user_level) { $script = ""; // filtro sui media: // dovrebbe verificare se nel profilo dell'utente si richiede una navigazione text-only, se il browser �abilitato etc // per ora controlla solo se il browser supporta javascript // qui va inserita la versione CD/WEB $dataAr = array(); if (!empty($this->media) && !is_object($this->media)) { $browser = $HTTP_USER_AGENT; $javascript_ok = check_javascriptFN($browser); $mediaAr = $this->media; $dataAr = array(); foreach ($mediaAr as $res_id) { $mediaObj = new Media($res_id); $media_name = $mediaObj->file_name; $media_type = $mediaObj->media_type; // vito, 20 mar 2009 if ($this->type == ADA_NOTE_TYPE || $this->type == ADA_PRIVATE_NOTE_TYPE) { $exploded_id = explode('_', $this->id); $course_id = $exploded_id[0]; $course_ha = $dh->get_course($course_id); if (AMA_DataHandler::isError($course_ha)) { // come gestire errore } $author_dir = $course_ha['id_autore']; } else { $author = $this->author['username']; //if (empty($media_path)) { $clause = "username = '******'"; $field_list = array(); $res = $dh->find_authors_list($field_list, $clause); if (AMA_DataHandler::isError($res)) { $msg = $res->getMessage(); // header("Location: $error?err_msg=$msg"); } $author_dir = $res['0']['0']; } // vito, 20 feb 2009, mancava uno / $media_path = "services/media/" . $author_dir . "/"; if (!empty($media_name)) { if ($media_type < 3 || !stristr($media_name, "http:")) { // 0,1,2 + files if (MEDIA_LOCAL_PATH != null) { $file_name = MEDIA_LOCAL_PATH . $media_path . $media_name; $file_name_http = MEDIA_LOCAL_PATH . $media_path . $media_name; } else { /* * vito, 20 feb 2009, controllo che $root_dir e $http_root_dir * terminino con / */ if ($root_dir[strlen($root_dir) - 1] == '/') { $file_name = $root_dir . $media_path . $media_name; } else { $file_name = $root_dir . '/' . $media_path . $media_name; } if ($http_root_dir[strlen($http_root_dir) - 1] == '/') { $file_name_http = $http_root_dir . $media_path . $media_name; } else { $file_name_http = $http_root_dir . '/' . $media_path . $media_name; } } } else { // http $file_name = $media_name; $file_name_http = $media_name; } } //if (!empty($media_name)) { // $file_name = $root_dir . $media_path . $media_name; // $file_name_http = $http_root_dir . $media_path . $media_name; if ($media_type < 3 && file_exists($file_name)) { // Controllo del tipo di media switch ($media_type) { //case 0: //img case _IMAGE: $size = GetImageSize($file_name); $x = $size[0]; $y = $size[1]; $r = 10; /* $debug=1; mydebug(__LINE__,__FILE__,$file_name); mydebug(__LINE__,__FILE__,$size); $debug=0; */ switch (IMG_VIEWING_MODE) { // it would be better to use a property instead case 2: // full img in page, only icon here if ($javascript_ok) { $link_media = "<img src=\"img/_img.png\"> <A HREF=\"#\" ONCLICK=\"newWindow('{$file_name_http}',{$x},{$y})\">{$media_name}</a>"; } else { $link_media = "<img src=\"img/_img.png\"> <a href=\"{$file_name_http}\" target=\"img_win\" >{$media_name}</a>"; } break; case 1: // icon in page, a reduced size preview here if ($javascript_ok) { $link_media = "<img src=\"include/resize.php?img={$file_name}&ratio={$r}\"> <A HREF=\"#\" ONCLICK=\"newWindow('{$file_name_http}',{$x},{$y})\">{$media_name}</a>"; } else { $link_media = "<img src=\"include/resize.php?img={$file_name}&ratio={$r}\"> <a href=\"{$file_name_http}\" target=\"img_win\" >{$media_name}</a>"; } break; case 0: // icon in page, icon here // icon in page, icon here default: if ($javascript_ok) { $link_media = "<img src=\"img/_img.png\"> <A HREF=\"#\" ONCLICK=\"newWindow('{$file_name_http}',{$x},{$y})\">{$media_name}</a>"; } else { $link_media = "<img src=\"img/_img.png\"> <a href=\"{$file_name_http}\" target=\"img_win\" >{$media_name}</a>"; //mydebug(__LINE__,__FILE__,$link_media); } } break; //case 1: //case 1: case _SOUND: $link_media = "<img src=\"img/_audio.png\"> <a href=\"{$file_name_http}\">{$media_name}</a>"; break; //case 2: //case 2: case _VIDEO: $link_media = "<img src=\"img/_video.png\"> <a href=\"{$file_name_http}\" target=\"img_win\" >{$media_name}</a>"; break; } } else { //if ($media_type == 3){ if ($media_type == _LINK) { if (stristr($media_name, "http")) { $link_media = "<img src=\"img/_web.png\"> <a href=\"{$file_name_http}\" target=\"img_win\" >" . wordwrap($media_name, 20, "\n", 1) . "</a>"; } else { $link_media = "<img src=\"img/_linkext.png\"> <a href=\"{$file_name_http}\" target=\"img_win\" >{$media_name}</a>"; } } else { if ($media_type == _DOC && file_exists($file_name)) { $link_media = "<img src=\"img/_doc.png\"> <a href=\"{$file_name_http}\">{$media_name}</a>"; } else { //$link_media =$media_name.": ".translateFN("non riconosciuto"); $link_media = sprintf(translateFN("%s: non riconosciuto"), $media_name); } } } $ok_media = array('media' => $link_media); array_push($dataAr, $ok_media); } } /* */ if (count($dataAr)) { $t = new Table(); $t->initTable('0', 'center', '2', '0', '100%', '', '', '', '', '0', '0'); $t->setTable($dataAr, $caption = "", $summary = translateFN("Indice dei Media collegati")); $t->getTable(); return $t->data; } else { return $this->_wrapTextInSpan(translateFN('Nessuno'), 'noitem')->getHtml(); } } else { return $this->_wrapTextInSpan(translateFN('Nessuno'), 'noitem')->getHtml(); } //} // fine filtro media }
private static function display_messages_as_form($data_Ar = array(), $message_type = ADA_MSG_SIMPLE, $testers_dataAr = array()) { $common_dh = $GLOBALS['common_dh']; $javascript_ok = check_javascriptFN($_SERVER['HTTP_USER_AGENT']); $appointments_Ar = array(); if ($message_type == ADA_MSG_SIMPLE) { $list_module = 'list_messages.php'; $read_module = 'read_message.php'; $del_img = CDOMElement::create('img', 'src:img/delete.png, name:del_icon'); $del_img->setAttribute('alt', translateFN('Rimuovi il messaggio')); $del_text = translateFN('Cancella'); } else { $list_module = 'list_events.php'; $read_module = 'read_event.php'; $del_text = ''; } $order_by_author_link = CDOMElement::create('a', "href:{$list_module}?sort_field=id_mittente"); $order_by_author_link->addChild(new CText(translateFN('Autore'))); $order_by_time_link = CDOMElement::create('a', "href:{$list_module}?sort_field=data_ora"); $order_by_time_link->addChild(new CText(translateFN('Data ed ora'))); $order_by_subject_link = CDOMElement::create('a', "href:{$list_module}?sort_field=titolo"); $order_by_subject_link->addChild(new CText(translateFN('Oggetto'))); $order_by_priority_link = CDOMElement::create('a', "href:{$list_module}?sort_field=priorita"); $order_by_priority_link->addChild(new CText(translateFN('Priorità'))); $thead_data = array($order_by_author_link, $order_by_time_link, $order_by_subject_link, $order_by_priority_link, $del_text, translateFN('Letto'), ''); foreach ($data_Ar as $tester => $appointment_data_Ar) { //$udh = UserDataHandler::instance(self::getDSN($tester)); //$tester_info_Ar = $common_dh->get_tester_info_from_pointer($tester); $tester_id = $testers_dataAr[$tester]; // if (AMA_Common_DataHandler::isError($tester_info_Ar)) { // /* // * Return a ADA_Error with delayed error handling. // */ // return new ADA_Error($tester_info_Ar,translateFN('Errore in ottenimento informazioni tester'), // NULL,NULL,NULL,NULL,TRUE); // } $tester_TimeZone = MultiPort::getTesterTimeZone($tester); $offset = get_timezone_offset($tester_TimeZone, SERVER_TIMEZONE); foreach ($appointment_data_Ar as $appointment_id => $appointment_Ar) { // trasform message content into variable names $sender_id = $appointment_Ar[0]; $date_time = $appointment_Ar[1]; //$subject = $appointment_Ar[2]; /* * Check if the subject has an internal identifier and remove it. */ //$subject = preg_replace('/[0-9]+#/','',$appointment_Ar[2],1); $subject = ADAEventProposal::removeEventToken($appointment_Ar[2]); $priority = $appointment_Ar[3]; $read_timestamp = $appointment_Ar[4]; $date_time_zone = $date_time + $offset; $zone = translateFN("Time zone:") . " " . $tester_TimeZone; $data_msg = AMA_DataHandler::ts_to_date($date_time_zone, "%d/%m/%Y - %H:%M:%S") . " " . $zone; // $data_msg = AMA_DataHandler::ts_to_date($date_time, "%d/%m/%Y - %H:%M:%S"); // transform sender's id into sender's name // $res_ar = $udh->find_users_list(array("username"), "id_utente=$sender_id"); // if (AMA_DataHandler::isError($res_ar)) { // $sender_username = ''; // } // else { // $sender_username = $res_ar[0][1]; // } $sender_username = $appointment_Ar[6]; //$msg_id = $tester_info_Ar[0].'_'.$appointment_id; $msg_id = $tester_id . '_' . $appointment_id; $url = HTTP_ROOT_DIR . '/comunica/' . $read_module . '?msg_id=' . $msg_id; $subject_link = CDOMElement::create('a', "href:{$url}"); $subject_link->addChild(new CText($subject)); /* * If this is a list of simple messages, then deleting is allowed. * Otherwise it is disabled. */ if ($message_type == ADA_MSG_SIMPLE) { $delete = CDOMElement::create('checkbox', "name:form[del][{$msg_id}],value:{$msg_id}"); $action_link = CDOMElement::create('a', "href:{$list_module}?del_msg_id={$msg_id}"); $action_link->addChild($del_img); } else { $delete = ''; $delete_link = ''; // PROVA, POI RIMETTERE A POSTO $userObj = $_SESSION['sess_userObj']; /* if($userObj instanceof ADAPractitioner) { $event_token = ADAEventProposal::extractEventToken($appointment_Ar[2]); $href = HTTP_ROOT_DIR . '/tutor/eguidance_tutor_form.php?event_token=' . $event_token; $action_link = CDOMElement::create('a', "href:$href"); $action_link->addChild(new CText(translateFN('View eguidance session data'))); } * */ } $read = CDOMElement::create('checkbox', "name:form[read][{$msg_id}],value:{$msg_id}"); if ($read_timestamp != 0) { $read->setAttribute('checked', 'checked'); } if (!isset($action_link)) { $action_link = null; } $appointments_Ar[] = array($sender_username, $data_msg, $subject_link, $priority, $delete, $read, $action_link); } } if (count($appointments_Ar) > 0) { $table = BaseHtmlLib::tableElement('', $thead_data, $appointments_Ar); if (!isset($module)) { $module = null; } $form = CDOMElement::create('form', "name:form, method:post, action:{$module}"); $form->addChild($table); $div = CDOMElement::create('div', 'id:buttons'); $submit = CDOMElement::create('submit', 'name:btn_commit value:' . translateFN('Salva')); $reset = CDOMElement::create('reset', 'name:btn_reset value:' . translateFN('Ripristina')); $div->addChild($submit); $div->addChild($reset); $form->addChild($div); return $form; } else { if ($message_type == ADA_MSG_SIMPLE) { return new CText(translateFN('Non ci sono nuovi messaggi')); } return new CText(translateFN('Non ci sono nuovi appuntamenti')); } }